FabulaTech Forum Newbie
InvalidCastException in ftvspcnet.dll
« on: May 6th, 2022, 11:57am »
I am trying to build an app that opens a COM-port in .NET (C# VS2022, Win 11, x64).
The demo project provided by FabulaTech named VSPCDemo.sln is working flawless in VS2022.
I have ported relevant parts of this code into my project (same .NET runtime version) and I am also able to open and close ports. I can send bytes without a problem and I have registered to OnRxChar event and this event is triggered once bytes are received.
BUT in my application any incoming byte raises an exception in the underlying library ftvspcnet.dll.
Output Log from VS:
Exception thrown: 'System.InvalidCastException' in ftvspcnet.dll
This happens for every incoming byte which causes the communication to slow down severely rendering it impossible for my use case. This happens also, if I do not register the OnRxChar event but poll for InQueueBytes > 0. The exception is fired immediately after a byte is received and processed by ftvspcnet.dll. I have no option to trace this issue myself.
Project settings are identical as in the sample. Everything is the same but I keep getting this exception.