'Expression can't be evaluated, because there is a negative frame on top of the stack

I'm creating a test station program in C# where I communicate with a test pcb through a ftdi to Uart cable. All works fine but sometimes my application crashes. Through debugging I found that the crash occures on the FTDI object InterfaceIdentifier because the Expression can't be evaluated, because there is a negative frame on top of the stack. What I'm trying to do in this line is

ftStat = myMod.Write(txbuf, bytestowrite, ref numBytesWritten

I can check that the Port is open.

What I don't understand is that sometimes it runs for several days and on other times it just crashes after a few hours while doing the same stuff.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source