0

I am trying to buld a DLL in VB.NET 2010 that will be use to control a vending machine. Whin a call into the DLL to a function to open and setup the comport the first time its opens it just fine, but if a call into the DLL again it does not know that the port is open even if it is still open. I can check with another program and is shows the port is open and if I try to call into the DLL again to open the port I get an error that the port is already open. Any idea how to set this up so it will work.

I need to open and config the com port in one call that leaves it open and then in other call use the com port to talk the equipment in the machine without closing the com port untill it is required to close it.

4

1 に答える 1

0

開いている接続のリストで静的 (共有) フィールドを使用し、COM ポートを使用する前に確認することができます。

アプリケーションがクラッシュした場合も、開いているすべてのポートが Dispose メソッドを使用して閉じられることを確認してください。

于 2012-06-03T21:07:36.307 に答える