Occasional crash on unhandled exception in internal async operation in modbus slave

215 views
Skip to first unread message

Franco Tiveron

unread,
Feb 16, 2016, 8:54:55 PM2/16/16
to NModbus
Hello, I have implemented an application (both master and slave TCP). A PLC is reading 27 registers from the datastore every second. Sometime the application crashes and the following is reported in eventviewer

Application: rOCSue.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
   at Modbus.Device.ModbusMasterTcpConnection.CatchExceptionAndRemoveMasterEndPoint(System.Action, System.String)
   at Modbus.Device.ModbusMasterTcpConnection.ReadFrameCompleted(System.IAsyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr)
   at System.Net.ContextAwareResult.CompleteCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Net.ContextAwareResult.Complete(IntPtr)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Looking at the source is not easy (for me) to understand what Invalid Operation does the code perform.

Help please.

michele

unread,
Feb 23, 2016, 5:52:41 PM2/23/16
to NModbus
If you are using the latest old sources, there is a bug in version 1.11.0.0, due to the fact that the original author started to support the Compact Framework (dead on arrival) and removed the IDisposable on ModbusMaster.
You can use build 1.10.0.0, or use the new NModbus library, or I pushed an older version of NModbus just for reference.
Check these comments.

http://www.mesta-automation.com/modbus-with-c-sharp-libraries-examples/#comment-392
Reply all
Reply to author
Forward
0 new messages