Author Topic: Debug message  (Read 1400 times)

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Debug message
« on: March 15, 2017, 01:18:07 AM »
I have a page with a DataSubscriber2 on it, and each time I open this page at runtime I get a VBA error, which points to this object. The error details are copied below. I have checked and double checked the setup of the object to make sure I've entered all my address details correctly, and written the VBA correctly, and I can't find a fault. Also - if I click Continue, the code continues to work. I know this, because the DataSubscriber is monitoring all of the date/time data from the PLC, and updating some text on the page to show the current PLC date/time. While the error is on the screen, and after I click continue, it continues to count up the seconds and minutes just fine.

I tried running the page from within the development environment, and I get the same error. If I click continue, it dumps out of the runtime with another error. While playing with this, I accidentally unchecked the "break when this type of error is encountered", and now it goes straight to dumping out of runtime as soon as I try and load this page.

So, a couple of things I'm trying to work out:
- How do I get that box re-checked, so it "breaks" on this type of error again?
- What's going on with the error in the first place, and how do I fix it?

Error data:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at MfgControl.AdvancedHMI.Display_SystemSettings.DataSubscriber21_DataChanged(Object sender, PlcComEventArgs e) in Z:\Alan\2205 Watering System\Programs\SCADA\AdvancedHMI\Display_SystemSettings.vb:line 18
   at AdvancedHMIControls.DataSubscriber2.DataChangedSync(Object sender, PlcComEventArgs e) in Z:\Alan\2205 Watering System\Programs\SCADA\AdvancedHMIControls\Components\DataSubscriber2.vb:line 253


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
AdvancedHMI
    Assembly Version: 3.9.9.18
    Win32 Version: 3.9.9.18
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/AdvancedHMI.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 10.0.0.0
    Win32 Version: 14.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
MfgControl.AdvancedHMI.Drivers
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/MfgControl.AdvancedHMI.Drivers.DLL
----------------------------------------
AdvancedHMIControls
    Assembly Version: 3.9.9.18
    Win32 Version: 3.9.9.18
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/AdvancedHMIControls.DLL
----------------------------------------
MfgControl.AdvancedHMI.Controls
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/MfgControl.AdvancedHMI.Controls.DLL
----------------------------------------
AdvancedHMIDrivers
    Assembly Version: 3.9.9.18
    Win32 Version: 3.9.9.18
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/AdvancedHMIDrivers.DLL
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Debug message
« Reply #1 on: March 15, 2017, 02:01:43 AM »
In your code in the DataChanged Event, add this check:
Code: [Select]
If e.Values IsNot Nothing AndAlso E.Values.Count>0 then
   If e.ErrorCode=0 then
.
.
<YOUR CODE>
.
.
  Else
     MsgBox("Error from Driver=" & e.ErrorMessage)
  End If
End If

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Debug message
« Reply #2 on: March 17, 2017, 01:30:51 AM »
Thanks Archie, I'll give that a try. Do you have any idea how to re-enable the "break" on that error condition?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Debug message
« Reply #3 on: March 17, 2017, 07:44:38 AM »
Do you mean make the program stop again when the error happens?

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Debug message
« Reply #4 on: March 17, 2017, 12:36:06 PM »
Archie,

I think he means within Visual Studio so he knows the error is occurring during debug.

ASF,

Which version of Visual Studio are you using?

For 2015 see this link: https://blogs.msdn.microsoft.com/visualstudioalm/2015/02/23/the-new-exception-settings-window-in-visual-studio-2015/

Rich

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Debug message
« Reply #5 on: March 19, 2017, 05:23:46 PM »
Yep, that's what I was after! Thanks!

And yes, using Visual Studio 2015.

I'll report back on the fix when I get a chance to drop my modified code in.

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Debug message
« Reply #6 on: March 24, 2017, 02:46:31 AM »
With my code wrapped in "If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then", I still get an exception...

Code: [Select]
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at MfgControl.AdvancedHMI.Display_SystemSettings.DataSubscriber21_DataChanged(Object sender, PlcComEventArgs e) in Z:\Alan\2205 Watering System\Programs\SCADA\AdvancedHMI\Display_SystemSettings.vb:line 23
   at AdvancedHMIControls.DataSubscriber2.DataChangedSync(Object sender, PlcComEventArgs e) in Z:\Alan\2205 Watering System\Programs\SCADA\AdvancedHMIControls\Components\DataSubscriber2.vb:line 253


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
AdvancedHMI
    Assembly Version: 3.9.9.18
    Win32 Version: 3.9.9.18
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/AdvancedHMI.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 10.0.0.0
    Win32 Version: 14.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
MfgControl.AdvancedHMI.Drivers
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/MfgControl.AdvancedHMI.Drivers.DLL
----------------------------------------
AdvancedHMIControls
    Assembly Version: 3.9.9.18
    Win32 Version: 3.9.9.18
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/AdvancedHMIControls.DLL
----------------------------------------
MfgControl.AdvancedHMI.Controls
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/MfgControl.AdvancedHMI.Controls.DLL
----------------------------------------
AdvancedHMIDrivers
    Assembly Version: 3.9.9.18
    Win32 Version: 3.9.9.18
    CodeBase: file:///C:/Watering%20System/Programs/SCADA/AdvancedHMI/bin/Debug/AdvancedHMIDrivers.DLL
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Debug message
« Reply #7 on: March 24, 2017, 08:09:14 AM »
Add an additional check for e:

If e IsNot Nothing AndAlso e.Values IsNot Nothing AndAlso e.Values.Count>0 then

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Debug message
« Reply #8 on: April 16, 2017, 10:42:54 PM »
I worked it out in the end. It seems that I'm trying to do something with it before it's had a chance to read all of the "last value" items from the collection.

I put this check at the start, and it solved the problem:
Code: [Select]
If e.ErrorId = 0 And DataSubscriber21.PLCAddressValueItems(DataSubscriber21.PLCAddressValueItems.Count - 1).LastValue IsNot Nothing Then
This way it doesn't try to do anything until it has retrieved a "last value" value from the last item in the collection. I'm assuming that the data subscriber gets the values in the order they appear in the collection (i.e. from (0) to (count-1) ) so that if it has the last one, it must have all the previous ones as well.

In any case, it's stopped the error.