|
-
Apr 5th, 2011, 08:21 AM
#1
Catching NullReferenceException
Hello, I'm totally confused about my IDE behavior.
When I debug a program my IDE simply does not catch System.NullReferenceException - execution continues as if there were nothing wrong.
I may sound crazy, but this is a medical fact.
Moreover, when I go to the menu Debug/Exceptions System.NullReferenceException is not even in the list
(Common Language Runtime Exceptions).
I manually add it (there is the Add button) and I put a checkmark in the 'Thrown' and 'User unhandled' column - now IDE catches it, but after I re-load the project the situation re-appears - and NullReferenceException is not on the list again. What may be wrong?
Update:
No, when I step through the code the execution does not continue but exits the current block of code (sub or function). There were no Try...Catch blocks and there is a message: A System.NullReferenceException occured in MSCorlib.dll...
But why doesn't the debugger stop at this line?
Last edited by cicatrix; Apr 5th, 2011 at 09:03 AM.
-
Apr 5th, 2011, 09:27 AM
#2
Re: Catching NullReferenceException
You're corrupt...or at least your VS is. I have the System.NullReferenceException, so assuming that you are not blind, I would say that a VS file has been corrupted. Which one would be a bit hard to find. When you start VS, one of the files is failing on load. There may be a log file entry for this, though I have never had such an issue, so haven't gone looking.
You can add one, which means that something has to be written somewhere. Normally, this should give you some clue because it would be the most recently changed file...except that it looks like it might not be saving.
EDIT: That's probably not all that useful. VS is a sprawling mass. I took a look around, and did find a file of interest, but not interest for your problem, exactly. Instead, it looks like the XML file that holds the standard error messages. I was tempted to 'customize' some of my exceptions, but decided not to.
Last edited by Shaggy Hiker; Apr 5th, 2011 at 09:35 AM.
My usual boring signature: Nothing
 
-
Apr 5th, 2011, 12:56 PM
#3
Re: Catching NullReferenceException
This is possible, of course, but I checked on a 'clean project'. NullReference was caught and the debugger reported it. Therefore, there must be something with the project itself. Is there anything I can check with my project?
-
Apr 5th, 2011, 01:17 PM
#4
Re: Catching NullReferenceException
When you checked on the clean project, did you go into Ddbug|Exceptions to see whether System.NullReferenceException was there?
I was a bit surprised to see that the exceptions settings follows the project. I guess that makes a certain amount of sense, but I was kind of expecting them to be like IDE settings rather than project level settings. I haven't gotten rid of one to see whether that is project specific, but since the checked state of the exceptions is project specific, I would expect that changes to the exception list is also project specific.
However, that also means that the exceptions are stored in project files...somewhere. I have looked at most of those over the years, and I don't remember ever seeing anything like that.
I would guess that in your clean project, the exception is on the list, though you might as well confirm it. After that, it comes down to something getting altered in the project files.
My usual boring signature: Nothing
 
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
|