Author Topic: Solved! EthernetIPforCLXCom1.Dispose not disposing of the connection  (Read 1419 times)

johwaa

  • Newbie
  • *
  • Posts: 20
    • View Profile
Hi Guys,

I'm trying to create an app that will scan the PLCs in a list to see if the PLC battery needs changing. So I added a EthernetIPforCLXCom1 control named "GeneralCLXCom" (I just renamed the default name for the control since I thought that I would be needing more than one), and created a list of (ControlLogix) PLCs to read, read the state of "Controller.BatteryLow" in that PLC, print the result, and then I *try* to dispose of the control with these two lines:

GeneralCLXCom.CloseConnection()
GeneralCLXCom.Dispose()

They don't appear to be doing anything, and if left unchecked, VB.Net 2010 will throw an exception once the number of connections has reached 11. As a poor work around, I bumped up the upper limit of the DLL array to 1000.

The code does run through the Dispose function, but doesn't it need to decrement MyDLLInstance as well?


Thanks!

« Last Edit: June 05, 2014, 07:56:49 PM by johwaa »

johwaa

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: EthernetIPforCLXCom1.Dispose not disposing of the connection
« Reply #1 on: June 05, 2014, 07:56:14 PM »
Well, I'm back...

I added a line to the Dispose Sub

...    If DLL(MyDLLInstance).Connections <= 1 Then
                CloseConnection()
                DLL(MyDLLInstance).dispose(disposing)
>>>> This is what I added >>>>                DLL(MyDLLInstance) = Nothing
            Else
                DLL(MyDLLInstance).Connections -= 1
            End If
        End If ...

Now it works like a charm.


BTW Thanks Archie for your excellent work on AdvancedHMI!!