开发者

Strange unhandled exception

I've been developing a windows app in .net C# for GSM Modems and i've come across a strange error:

System.ObjectDisposedException was unhandled
  Message="The secure parameter identifier was closed (pt: O parâmetro identificador seguro foi fechado)"
  Source="System"
  ObjectName=""
  StackTrace:
       at Microsoft.Win32.UnsafeNativeMethods.GetOverlappedResult(SafeFileHandle hFile, NativeOverlapped* lpOverlapped, Int32& lpNumberOfBytesTransferred, Boolean bWait)
       at System.IO.Ports.SerialStream.EventLoopRunner.Wa开发者_C百科itForCommEvent()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

This has only happened recently - i have no idea why... could it be i am disposing of a SerialPort and getting an answer of the modem later?? - shouldn't this be avoided when i dispose of the SerialPort?


System.ObjectDisposedException always occurs when you are trying to use disposed object, so you've answered on you question by your own =)


Did you register a handler on the port's DataReceived event? If so, you should probably unregister it (and maybe add a Sleep() call to allow any currently running handler to finish) before closing the port.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜