HighTechTalks DotNet Forums  

ManualResetEvent.Set throws :"The handle is invalid."

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss ManualResetEvent.Set throws :"The handle is invalid." in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
John Aldrin
 
Posts: n/a

Default ManualResetEvent.Set throws :"The handle is invalid." - 10-26-2006 , 07:30 PM






Hi,

Anyone know why the Set method would throw a System.IO.IOException w/a
message of "The handle is invalid."?

I have used Windbg to examine the ManualResetEvent object and it appears to
be valid (handle > 0 value, safeWaitHandle private var agress w/handle, state
of 4)

Following outlines how the ManualResetEvent is created and used.

ui thread creates obj
Event is created in obj ctor
object is added to a list
ui thread calls WaitOne on event
background thread wakes up and uses obj to do some work
Set method is called on event when work is complete - >exception is throw
here.

Thanx

jra



Reply With Quote
  #2  
Old   
Jeffrey Tan[MSFT]
 
Posts: n/a

Default RE: ManualResetEvent.Set throws :"The handle is invalid." - 10-27-2006 , 02:41 AM






Hi John,

Do you use .Net1.1 or .Net2.0? ManualResetEvent.Set() method has different
implementation under .Net1.1 and 2.0.

By reviewing your code logic steps, I did not find anything may cause this
exception. Can you provide the detailed stack trace of this exception?
Actually, I have searched a lot of internal database and public resource
regarding this exception with ManualResetEvent.Set() method, however, I did
not find much useful information. It seems that this issue is not a common
reported problem.

Also, since your code logic steps are not very complex, is it possible for
you to create a little sample project to help me reproduce this problem?
This will be more efficient for us to debug.

I will wait for your further information. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
John Aldrin
 
Posts: n/a

Default RE: ManualResetEvent.Set throws :"The handle is invalid." - 10-27-2006 , 08:33 AM



Hi Jeffery,

Here is the stack trace

Exception: System.IO.IOException
Message: The handle is invalid.

Source: mscorlib
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.Threading.EventWaitHandle.Set()
at
Starkey.Hia.Audiology.Communications.TaskExecutive .TaskList.ExecuteNextWaitingTask(TimeStamp&
nextTaskTime) in
C:\Dev\Shared\Components\Audiology\1.2\Projects\Au diology.Communications\TaskExecutive.cs:line 1395
at
Starkey.Hia.Audiology.Communications.TaskExecutive .CommunicationsThreadProc()
in
C:\Dev\Shared\Components\Audiology\1.2\Projects\Au diology.Communications\TaskExecutive.cs:line 1123



""Jeffrey Tan[MSFT]"" wrote:

Quote:
Hi John,

Do you use .Net1.1 or .Net2.0? ManualResetEvent.Set() method has different
implementation under .Net1.1 and 2.0.

By reviewing your code logic steps, I did not find anything may cause this
exception. Can you provide the detailed stack trace of this exception?
Actually, I have searched a lot of internal database and public resource
regarding this exception with ManualResetEvent.Set() method, however, I did
not find much useful information. It seems that this issue is not a common
reported problem.

Also, since your code logic steps are not very complex, is it possible for
you to create a little sample project to help me reproduce this problem?
This will be more efficient for us to debug.

I will wait for your further information. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
  #4  
Old   
Gaurav Khanna [MSFT]
 
Posts: n/a

Default Re: ManualResetEvent.Set throws :"The handle is invalid." - 10-27-2006 , 03:36 PM



Hi John,

Can you invoke the GetLastError API and see what is the exact error? I
created a repro (see attached file) for the steps you outlined below and it
seems to work for me on .NET FX 2.0

--
Cheers!
Gaurav Khanna
-------------------------------------------------------------
WinToolZone - www.wintoolzone.com
Inside and Out - www.wintoolzone.com/blog/
-------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.

"John Aldrin" <Jrax (AT) newsgroups (DOT) nospam> wrote

Quote:
Hi,

Anyone know why the Set method would throw a System.IO.IOException w/a
message of "The handle is invalid."?

I have used Windbg to examine the ManualResetEvent object and it appears
to
be valid (handle > 0 value, safeWaitHandle private var agress w/handle,
state
of 4)

Following outlines how the ManualResetEvent is created and used.

ui thread creates obj
Event is created in obj ctor
object is added to a list
ui thread calls WaitOne on event
background thread wakes up and uses obj to do some work
Set method is called on event when work is complete - >exception is throw
here.

Thanx

jra



Reply With Quote
  #5  
Old   
Jeffrey Tan[MSFT]
 
Posts: n/a

Default RE: ManualResetEvent.Set throws :"The handle is invalid." - 10-29-2006 , 10:15 PM



Hi John,

Thanks for the feedback.

Based on the stack trace information, I am assuming that you are using
.Net2.0. And your stack trace reveals that ManualResetEvent.Set() method
fails on the win32 SetEvent API, and the win32 error code is 0x6, which
means "The handle is invalid.".

This exception looks like strange, since as "Gaurav Khanna [MSFT]" said,
this exception can not be reproduced by creating a repro with the same code
logic steps. I suspect this exception is your environment specific. Have
you tried the sample code "Gaurav Khanna [MSFT]" provided on your side?
Does this exception still generate in this sample code?

Since this stack trace can not reveal more information. Is it possible for
you to create a little sample project to help us reproduce this problem?
This will be more efficient for us to troubleshoot.

I will wait for your sample project. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #6  
Old   
John Aldrin
 
Posts: n/a

Default Re: ManualResetEvent.Set throws :"The handle is invalid." - 10-30-2006 , 06:17 PM



Not sure if u are suggesting I call Marshall.GetLastWin32Error or to do a
platform invoke for GetLastError. MSDN says it is not safe to do a platform
invoke for GetLastError.

Thanx

jra

How do I access a attached file from a news group message?


"Gaurav Khanna [MSFT]" wrote:

Quote:
Hi John,

Can you invoke the GetLastError API and see what is the exact error? I
created a repro (see attached file) for the steps you outlined below and it
seems to work for me on .NET FX 2.0

--
Cheers!
Gaurav Khanna
-------------------------------------------------------------
WinToolZone - www.wintoolzone.com
Inside and Out - www.wintoolzone.com/blog/
-------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.

"John Aldrin" <Jrax (AT) newsgroups (DOT) nospam> wrote in message
news:56564249-B3E9-4B5F-91A2-F44CF5857E4E (AT) microsoft (DOT) com...
Hi,

Anyone know why the Set method would throw a System.IO.IOException w/a
message of "The handle is invalid."?

I have used Windbg to examine the ManualResetEvent object and it appears
to
be valid (handle > 0 value, safeWaitHandle private var agress w/handle,
state
of 4)

Following outlines how the ManualResetEvent is created and used.

ui thread creates obj
Event is created in obj ctor
object is added to a list
ui thread calls WaitOne on event
background thread wakes up and uses obj to do some work
Set method is called on event when work is complete - >exception is throw
here.

Thanx

jra



Reply With Quote
  #7  
Old   
Jeffrey Tan[MSFT]
 
Posts: n/a

Default Re: ManualResetEvent.Set throws :"The handle is invalid." - 10-31-2006 , 01:33 AM



Hi John,

There is no need to call Marshall.GetLastWin32Error now. "The handle is
invalid" is actually win32 "0x6" in numeric.

To get the attached files in newsgroup, you should use Outlook Express, can
not use IE. I have downloaded that sample file and sent an email to you
with the file. You may check it in your mailbox.

Additionally, if you can create a sample reproduce project, please feel
free to send it to me. It would be efficient for us to troubleshoot the
root cause with the reproduce project.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #8  
Old   
John Aldrin
 
Posts: n/a

Default Re: ManualResetEvent.Set throws :"The handle is invalid." - 11-06-2006 , 10:06 AM



Jeffery,

Could u explain why Windows thinks the handle is invalid?

Thanx

jra

""Jeffrey Tan[MSFT]"" wrote:

Quote:
Hi John,

There is no need to call Marshall.GetLastWin32Error now. "The handle is
invalid" is actually win32 "0x6" in numeric.

To get the attached files in newsgroup, you should use Outlook Express, can
not use IE. I have downloaded that sample file and sent an email to you
with the file. You may check it in your mailbox.

Additionally, if you can create a sample reproduce project, please feel
free to send it to me. It would be efficient for us to troubleshoot the
root cause with the reproduce project.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
  #9  
Old   
Jeffrey Tan[MSFT]
 
Posts: n/a

Default Re: ManualResetEvent.Set throws :"The handle is invalid." - 11-06-2006 , 10:18 PM



Hi John,

Thanks for your feedback.

Without reproducing the exception on my side, it is hard for me to find out
why the handle is recognized as invalid. So I still recommend you try to
create a sample project to help us reproduce the problem. Thanks for your
understanding.

Additionally, if you want to debug this situation yourself, you may use
windbg to attach and handle this exception. Then you may use "!handle
[hanlde_value] 7" command in windbg to dump out the information regarding
this invalid handle. I assume the windbg output will reveal some more
information regarding this handle.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.