我继承的代码不断崩溃,并出现以下错误(根本没有改变):
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 对话框(带有继续选项和堆栈跟踪)。
我查过了,与以下无关线程中止
我该如何尝试从堆栈跟踪中找到此问题的原因,而不是在应用程序的代码中?
从引用 System.IO.Ports.SerialStream.EventLoopRunner.WaitForCommEvent() 和 Microsoft.Win32.UnsafeNativeMethods 的事实来看,我可能会担心您有一个具有访问端口的内部线程的 COM 组件,例如用于串行或 TCP/IP 数据。
看起来线程在启动序列期间抛出了异常。它可能正在尝试访问不可用或不存在的端口。此操作失败,并且异常未得到处理,因此会通过代码传播回来。
尝试记录来自 UnhandledException 事件的更多信息,以便了解这可能从哪里开始。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)