Hello

I have written a piece of code that works fine on my computer and all other computers that I have tried it on when running XP. I have tried it on a few machines running vista and they have all worked fine but one of my customers is running Vista and it comes up with an unhandled Exception error.

Dialouge box opens and says

Unhandled exception has occured in you applicayion

aobject reference not set to an instance of a object

When i click Details i get the attached

-----Inline Attachment Follows-----

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 WindowsApplication1.QSLights.frmSliderTest_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
QSLights
Assembly Version: 1.0.0.19943
Win32 Version:
CodeBase: file:///C:/Users/Jessi/AppData/Local/Apps/2.0/GYK04HXV.PVQ/M55VH7OB.29N/qsli..tion_5ae5e6c7ce756b7c_0001.0000_1428b29394264201/QSLights.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version:
Win32 Version: 8.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Configuration
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/__b77a5c561934e089/System.Xml.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.

Any idea what could be causeing this?

Dani AI

Generated

A NullReferenceException thrown from a form Load handler on a single machine usually means the Load code is dereferencing something that isn't present in that environment. Common causes to check first are: missing or inaccessible data files or resources, XML or DB reads that return Nothing/DBNull, ClickOnce/working-directory differences, a target-framework/platform mismatch, or a native dependency absent on that Vista box.

Add rapid diagnostics inside the Load handler so the failing machine can produce useful logs. Wrap the critical init code, log the full exception and any key variable values to a writable per-user file, then rethrow so local debugging still works. Example:

Try
    ' initialization that may fail
Catch ex As Exception
    Dim log = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "QSLights.log")
    File.AppendAllText(log, DateTime.Now.ToString("s") & " - " & ex.ToString() & Environment.NewLine)
    Throw
End Try

If the app is ClickOnce-deployed, relative paths often break. Resolve data files using the app base or ClickOnce data directory:

Dim xmlPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.xml")
If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
    xmlPath = Path.Combine(System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory, "config.xml")
End If
If Not File.Exists(xmlPath) Then
    ' handle missing file
End If

For database timestamp/null issues (as raised by ), always test for DBNull before converting:

Dim ts As Nullable(Of DateTime) = Nothing
If Not reader.IsDBNull(idx) Then ts = reader.GetDateTime(idx)

Note 's report that adding mscorlib changed behavior — manually referencing mscorlib is atypical and can hide the real problem. Verify the target .NET runtime on the customer machine, confirm Target Framework and CPU settings, and use assembly bind logging (fuslogvw) if assemblies are missing. Final checklist: enable scoped logging, reproduce under the same user account, verify data/file/DB availability, guard against DBNull, and produce a small diagnostic build for the customer.

Recommended Answers

All 3 Replies

Hello

I have written a piece of code that works fine on my computer and all other computers that I have tried it on when running XP. I have tried it on a few machines running vista and they have all worked fine but one of my customers is running Vista and it comes up with an unhandled Exception error.

Dialouge box opens and says

Unhandled exception has occured in you applicayion

aobject reference not set to an instance of a object

When i click Details i get the attached

I had a similar problem and by adding the MSCorLib to my references, I was able to get rid of the Null Refernce error on other machines.

-----Inline Attachment Follows-----

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 WindowsApplication1.QSLights.frmSliderTest_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
QSLights
Assembly Version: 1.0.0.19943
Win32 Version:
CodeBase: file:///C:/Users/Jessi/AppData/Local/Apps/2.0/GYK04HXV.PVQ/M55VH7OB.29N/qsli..tion_5ae5e6c7ce756b7c_0001.0000_1428b29394264201/QSLights.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version:
Win32 Version: 8.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Configuration
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version:
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/__b77a5c561934e089/System.Xml.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.

Any idea what could be causeing this?

I had a similar problem and once I added the MSCorLib to my references it seemed to go away. Also, in the compile I could NOT use the OneClick Deployment for some reason

how to over come from thr unhandeled execption error in vb

it's not worked in my case.. it's the error in back-end of my project.... for timestamp datatype....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.