如何调试"安全手柄已经关闭"错误 [英] How to debug "Safe handle has been closed" error

查看:1128
本文介绍了如何调试"安全手柄已经关闭"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

code总是崩溃了相当有力,出现以下错误(没有改变):

Code which I have inherited keeps crashing out rather powerfully with the following error (not changed at all):

System.ObjectDisposedException: Safe handle has been closed
   at Microsoft.Win32.UnsafeNativeMethods.GetOverlappedResult(
          SafeFileHandle hFile, NativeOverlapped* lpOverlapped, 
          Int32& lpNumberOfBytesTransferred, Boolean bWait)
   at System.IO.Ports.SerialStream.EventLoopRunner.WaitForCommEvent()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.
          ExecuteCodeWithGuaranteedCleanup(
          TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(
          ExecutionContext executionContext, ContextCallback callback, 
          Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, 
          ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

这是唯一被抓为previous开发人员增加了一个<一个href="http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx">AppDomain.UnhandledException事件。

This is only being caught as the previous developers added a AppDomain.UnhandledException Event.

如果我删除它,应用程序只是崩溃了与华生医生的消息(发送反馈等),而不是一般的.NET对话框(与继续选择和堆栈跟踪)。

If I remove it, the application just crashes out with a Dr Watson message (send feedback etc...) and not the usual .NET dialog (with the continue option and stack trace).

我已经检查,它是不相关的<一个href="http://stackoverflow.com/questions/1319003/safe-handle-has-been-closed-with-serialport-and-a-thread-in-c">Thread.Abort

I have checked and it is not related to Thread.Abort

我如何去试图寻找这个问题的原因,因为它的出现,从堆栈跟踪,而不是在$ C $申请了C?

How do I go about trying to find the cause of this issue, as it appears, from the stack trace, not to be in code of the application?

推荐答案

从事实System.IO.Ports.SerialStream.EventLoopRunner.WaitForCommEvent()和Microsoft.Win32.UnsafeNativeMethods被称为我敢大胆地说,你有一个有访问端口,例如内螺纹COM组件用于串行或TCP / IP的数据。

From the fact that System.IO.Ports.SerialStream.EventLoopRunner.WaitForCommEvent() and Microsoft.Win32.UnsafeNativeMethods are referred to I would hazard that you have a COM component that has internal threads accessing a port e.g. for serial or TCP/IP data.

它看起来像线程抛出一个异常,在它的启动顺序。也许它正试图访问不可用或不存在的端口。这将失败,并且异常没有处理,因此propogates背透code。

It would look like the thread throws an exception during it's start sequence. Possibly it is trying to access an unavailable or nonexistant port. This fails and the exception is not handled and thus propogates back through the code.

试图以得到的,其中,这可能从开始一个想法记录从UnhandledException事件的详细信息。

Trying logging more information from the UnhandledException Event in order to get an idea of where this may start from.

这篇关于如何调试&QUOT;安全手柄已经关闭&QUOT;错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆