我继承的代码经常崩溃,并且会出现以下错误(完全没有更改):
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()
这只被认为是之前的开发人员添加了AppDomain.UnhandledException事件所致。
如果我删除它,应用程序就会崩溃,并显示Dr Watson消息(发送反馈等...),而不是通常的.NET对话框(带有继续选项和堆栈跟踪)。
我已经检查过,与Thread.Abort无关。
如何尝试查找此问题的原因,因为从堆栈跟踪来看,它似乎不在应用程序的代码中?