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()
This is only being caught as the previous developers added a AppDomain.UnhandledException Event. 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).
I have checked and it is not related to Thread.Abort
How do I go about trying to find the cause of this issue, as it appears from the stack trace, to not be in code of the application?