Author Topic: Temporarily dispose ModbusRTUCom to allow use of another modbus DLL  (Read 1211 times)

scott.clark

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Using AdvancedHMI v3.97d with Visual Studio 2013

In my application, I created an instance of a driver component ModbusRTUCom on the Form[design].  I don't have any objects on my design form that poll or use the ModbusRTUCom.

In my form.vb, I  use  ModbusRTUCom.read and ModbusRTUCom.Write commands, which works fine. 

Then I have another ModbusDLL that I need to execute some commands from that needs to use the same serial port.

So I execute,

ModbusRTUCom.Dispose(), which allows me to exectute the ModbusDLL procedures.   Once completed I execute the ModbusDLL.Dispose()

But then when I try to  ModbusRTUCom.read , I get the exception" Cannot access a disposed object."

What do I need to do to work around this?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Temporarily dispose ModbusRTUCom to allow use of another modbus DLL
« Reply #1 on: February 27, 2015, 09:22:58 AM »
You will have to create driver instances in code:

Dim MyDriver as new ModbusRTUCom
MyDriver.PortName="COM1"
MyDriver.Baudrate="19200"
.
.
MyDriver.Read
.
.
MyDriver.Dispose