Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

I have a query regarding Object Not Set / Null Exceptions.
Now, I have a bizare situation where in my development environment a section of code is working with no issues. However, when the system goes live on a customer site sometimes (not often) I am getting an object not set exception throw up.

Now my question is, on a live environment how can I identify which object it is that is null/nothing? I cannot spot anything in the error message that tells me the name of the object that is throwing it, only the method that throws it?

Thanks
Posted

1 solution

The system generated error message box will allow you to "View Details" and the StackTrace which can tell you which of your methods is the location of the error and the actual line number. Using that information, modify your program to add Try...Catch blocks around all of your code that is setting objects in the method that experienced the exception. In each Catch block display a MessageBox or write to the EventLog some information about the error message and the location in your program.
 
Share this answer
 
v2
Comments
Pheonyx 16-Apr-13 8:58am    
Sorry it took so long to accept this as a solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900