I do some very simple error logging in my desktop application which speaks to equipment over a SerialPort
. One thing I do is setup a global exception catcher which does nothing but log the stack trace using:
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
I have one user who is having an error that is showing up in his logs. No one else is having the issue. I have no idea where to search for this uncaught exception. And I have no idea where I should try to catch it because I don't fully understand what it is.
I use the .NET SerialPort
object and all I do in open the port and do some simple reads and writes.
Is anyone able to explain what this exception is/means, what I can do to fix it, or where I should look to try and catch the error? Every time I touch my SerialPort
object I am doing so within try and catch blocks. So I am at a complete loss.
System.ObjectDisposedException: Safe handle has been closed
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()