.NET Forum / .NET Framework / CLR / November 2006
ManualResetEvent.Set throws :"The handle is invalid."
|
|
Thread rating:  |
John Aldrin - 27 Oct 2006 00:30 GMT 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
Jeffrey Tan[MSFT] - 27 Oct 2006 07:41 GMT 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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
John Aldrin - 27 Oct 2006 13:33 GMT 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\Audiology.Communications\TaskExecutive.cs:line 1395 at Starkey.Hia.Audiology.Communications.TaskExecutive.CommunicationsThreadProc() in C:\Dev\Shared\Components\Audiology\1.2\Projects\Audiology.Communications\TaskExecutive.cs:line 1123
> Hi John, > [quoted text clipped - 35 lines] > ================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 30 Oct 2006 04:15 GMT 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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Gaurav Khanna [MSFT] - 27 Oct 2006 20:36 GMT 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
 Signature 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.
> Hi, > [quoted text clipped - 20 lines] > > jra John Aldrin - 31 Oct 2006 00:17 GMT 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?
> Hi John, > [quoted text clipped - 26 lines] > > > > jra Jeffrey Tan[MSFT] - 31 Oct 2006 07:33 GMT 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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
John Aldrin - 06 Nov 2006 15:06 GMT Jeffery,
Could u explain why Windows thinks the handle is invalid?
Thanx
jra
> Hi John, > [quoted text clipped - 32 lines] > ================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 07 Nov 2006 03:18 GMT 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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|