System.NullReference exception

S

Steve

Hi All

I have a windows forms Application (SAM) in vb.net 2008 using .net framework
V2

One and only one customer out of 30 customers is getting errors daily where
they have to close and restart my application, sometimes several times a day

The customer has XP Home SP2

The event viewer shows the following although not always in the same
sequence

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5 1.0.0.0,
P6 48d969a4, P7 5, P8 0, P9 system.nullreferenceexception, P10 NIL.

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
microsoft.visualbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
system.componentmodel.win32, P10 NIL.

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
microsoft.visualbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
34ssps20bdj3nj0wmit5kamzhvglfzcc, P10 NIL.

Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
0.0.0.0, hang address 0x00000000.

I am lost as to what may be causing it and like I said it only happens to
the 1 customer

Any ideas what it could be and any ideas on how to troubleshoot it further
to find the exact cause?

Regards
Steve
 
A

Armin Zingler

Steve said:
Hi All

I have a windows forms Application (SAM) in vb.net 2008 using .net
framework V2

One and only one customer out of 30 customers is getting errors
daily where they have to close and restart my application, sometimes
several times a day

The customer has XP Home SP2

The event viewer shows the following although not always in the same
sequence

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5
1.0.0.0, P6 48d969a4, P7 5, P8 0, P9 system.nullreferenceexception,
P10 NIL.

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
microsoft.visualbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
system.componentmodel.win32, P10 NIL.

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
microsoft.visualbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
34ssps20bdj3nj0wmit5kamzhvglfzcc, P10 NIL.

Hanging application SAM.exe, version 1.0.0.0, hang module hungapp,
version 0.0.0.0, hang address 0x00000000.

I am lost as to what may be causing it and like I said it only
happens to the 1 customer

Any ideas what it could be and any ideas on how to troubleshoot it
further to find the exact cause?


How does you exception handling code look like?


Armin
 
K

kimiraikkonen

Hi All

I have a windows forms Application (SAM) in vb.net 2008 using .net framework
V2

One and only one customer out of 30 customers is getting errors daily where
they have to close and restart my application, sometimes several times a day

The customer has XP Home SP2

The event viewer shows the following although not always in the same
sequence

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5 1.0.0.0,
P6 48d969a4, P7 5, P8 0, P9 system.nullreferenceexception, P10 NIL.

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
microsoft.visualbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
system.componentmodel.win32, P10 NIL.

EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
microsoft.visualbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
34ssps20bdj3nj0wmit5kamzhvglfzcc, P10 NIL.

Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
0.0.0.0, hang address 0x00000000.

I am lost as to what may be causing it and like I said it only happens to
the 1 customer

Any ideas what it could be and any ideas on how to troubleshoot it further
to find the exact cause?

Regards
Steve

First try to have "try-catch" exception handling blocks as many as
possible in your project to catch "possible" exceptions, then based on
your description, make sure you have a exception block in form_load
and form_formclosed and formClosing events like:

' When the form is loaded
Private Sub Form1_Load(.....) Handles MyBase.Load

Try

' Do the stuff

Catch ex As Exception
Msgbox(ex.Messsage)

End Try

End Sub

....do the same for form's FormClosing and FormClosed events if your
application is not console one.

Additionaly, related to "System.NullReference" exception, presumably,
your variable may have no value assigned to the referenced object
anylonger as the reason of exception. Or the object is being
instantianted improperly after app restart.

Just it was a guess,

Onur Güzel
 
S

Steve

Hi All

Thanks for the responses

I have try/catch blocks in most of my routines

I also have a code in MyApplication_UnhandledExceptionroutine, which doesn't
fire (see below)

'writes unhandled exceptions to my log file

mymsgbox(e.Exception.Message & vbCr & e.Exception.InnerException.ToString)

If e.Exception.Message.Length > 200 Then

savetolog("Auto", e.Exception.Message.Substring(0, 199))

Else

savetolog("Auto", e.Exception.Message)

End If

The screen they get when the error occurs is not the usual .net screen
showing the error details, but the Microsoft screen with send report / don't
send buttons

Not sure if this makes a difference

Regards

Steve
 
F

Family Tree Mike

Just a shot in the dark, but can the user run your app as the administrator
successfully? Often this can be caused by some assumption of full
permissions somewhere in code. Things like reading or writing registry keys
may work 9 out of 10 times (or 29 out of 30 in your case).
 
J

Jialiang Ge [MSFT]

Hello Steve,

If an exception goes unhandled in a .NET 2.0 application, it will use
Windows Error Reporting to send a report automatically. Although we have
MyApplication_UnhandledExceptionroutine in the application (according to
your code snippet, I think it¡¯s added through the
Application.ThreadException event) and add try/catch in most of the
routines, there is actually another source of UnhandledException:

¡°AppDomain.UnhandledException¡±

Application.ThreadException is used to add the event handler for handling UI
thread exceptions. AppDomain.UnhandledException adds the event handler for
handling non-UI thread exception. In other words, if an exception is thrown
from a non-UI thread, Application.ThreadException is not able to capture it,
and it will go to the ¡°Windows Error Report¡± dialog. In addition, we need
to call
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
to set the unhandled exception mode to force all windows form error to go
through our handler. A typical example is:

SecurityPermission(SecurityAction.Demand, Flags =
SecurityPermissionFlag.ControlAppDomain)]
public static void Main(string[] args)
{
// Add the event handler for handling UI thread exceptions to the event.
Application.ThreadException += new
ThreadExceptionEventHandler(ErrorHandlerForm.Form1_UIThreadException);

// Set the unhandled exception mode to force all Windows Forms errors to
go through
// our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

// Add the event handler for handling non-UI thread exceptions to the
event.
AppDomain.CurrentDomain.UnhandledException +=
new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

// Runs the application.
Application.Run(new ErrorHandlerForm());
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
try
{
Exception ex = (Exception)e.ExceptionObject;
// dump the call stack here

// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "ThreadException";
myLog.WriteEntry(errorMsg + ex.Message + "\n\nStack Trace:\n" +
ex.StackTrace);
}
catch (Exception exc)
{
try
{
MessageBox.Show("Fatal Non-UI Error",
"Fatal Non-UI Error. Could not write the error to the event
log. Reason: "
+ exc.Message, MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
}

(See MSDN article:
http://msdn.microsoft.com/en-us/lib...ms.application.setunhandledexceptionmode.aspx)

With the above code, we can dump the call stack of the unhandled exception
in the exception handler, and see how the exception is thrown.

Regards,
Jialiang Ge ([email protected], remove ¡®online.¡¯)
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top