|
-
Jan 16th, 2006, 10:56 AM
#1
Thread Starter
Frenzied Member
Weird error when debugging
I am working on a project with a collegue using Source Control and i randomly get the following error when running on my machine whilst my collegue doesn't despite having the same code.
Sometimes i can click ok and proceed as normal but other times it kicks me back into Design mode.
It's more annoying than anything else but does anyone know what causes it or how to resolve it?
Code:
An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module.
Additional information: Object reference not set to an instance of an object.
-
Jan 16th, 2006, 02:11 PM
#2
Hyperactive Member
Re: Weird error when debugging
It basically means that you're trying to use some kind of object that is not instantiated. That's why the error is displaying a null reference exception. This error could be very tricky sometimes and my advice is to use the watch feature to see if you could find out which object is not instantiated. Somewhere you're trying to use an object that is not instantiated, just like if you're trying to use a primitive variables without declaring and instantiating that variable.
Jennifer
-
Jan 16th, 2006, 02:13 PM
#3
Hyperactive Member
Re: Weird error when debugging
Also you could try throwing the exception to see if you could locate the object that is not instantiated. It worked for me a few times, when you find that object, you then use it AFTER it has been instantiated and then you could take out the try / catch clause. - jennifer
-
Jan 16th, 2006, 05:17 PM
#4
Re: Weird error when debugging
When you get an unhandled exception you can hit the Break button and execution will halt as though you had used a breakpoint. In the case of a NullReferenceException, you can then simply test every reference (variable, property, function result) on the line until you find the one that is Nothing. You can then work backwards through your code until you find the place that you expected that object to be created. Note that you can use the Watch window to evaluate any expression you like, although there are other ways to test your references as well.
-
Jan 17th, 2006, 04:47 AM
#5
Thread Starter
Frenzied Member
Re: Weird error when debugging
If i break when i hit the error i just get informed that 'there is no code available for the current location'. That would also be the problem with throwing the error - where shall i throw it from?
As i said my collegue is running exactly the same code and not receiving the error.
Ultimately it isn't stopping me doing anything it's just annoying.
Last edited by Fishcake; Jan 17th, 2006 at 04:51 AM.
-
Jan 17th, 2006, 04:57 AM
#6
Re: Weird error when debugging
Do you have any idea what this "Unknown Module" might be? What assemblies are you referencing?
-
Jan 17th, 2006, 08:13 AM
#7
Thread Starter
Frenzied Member
Re: Weird error when debugging
aha! I hadn't thought of that. There are 3 non-standard references in the project which are company dll's for error handling, business logic etc. I'll look into those thanks.
Any idea why the error is random though and will sometimes not appear and all (when it does it is before any user input before main form is displayed)?
-
Jan 17th, 2006, 10:19 AM
#8
Frenzied Member
Re: Weird error when debugging
IIRC, when you get the "no code available..." message, you should be able to debug as long as you have to .pdb. I guess you have the source etc. to those references as they belong to your company?
As for why the error is random, that's a tough one - you need to figure out what's different. Could be data related - that is, you're using some data that your colleague is not. Could be something else.
I'd try to get with the authors of those .dlls. Maybe you can work together to figure out the problem. No offense to them, but if that's the case, they need better error handling.
You should be able to wrap a line of code in your app - maybe Application.Run in a try...catch block and get the stack trace when that error happens again. Giving the stack trace to the authors would help them alot.
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|