Strange exception in a strange thread
-
I've started getting a very strange exception in my program. An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. That happens sometimes when a window is created (not a specific window, has happened with messagebox and my own forms). I am using .Net version 1.1. This is my first app with 1.1, so maybe there was some important detail I missed that has changed from 1.0 to 1.1? I know threads and UI can cause a mess if done badly, but I am not doing any threading at all. It seems that before the exception occurs, a new thread with no name is created. VS cannot tell me anything about the thread: there is no call stack, the stack frame selector is unclickable... nothing.
-
I've started getting a very strange exception in my program. An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. That happens sometimes when a window is created (not a specific window, has happened with messagebox and my own forms). I am using .Net version 1.1. This is my first app with 1.1, so maybe there was some important detail I missed that has changed from 1.0 to 1.1? I know threads and UI can cause a mess if done badly, but I am not doing any threading at all. It seems that before the exception occurs, a new thread with no name is created. VS cannot tell me anything about the thread: there is no call stack, the stack frame selector is unclickable... nothing.
Many threads are created that handle various things, like painting a control or for asynchronous operations. You never know. Make sure you're compiling a debug build. There's other reasons you might not be able to use some of the debugging tools (threads are always funny when it comes to that), but just to eliminate the obvious I mentioned that. If you think it has something to do with threading, check that your application's
Main
entry point is attributed with theSTAThreadAttribute
, which is the main UI thread. Usually, though, you get different errors if your application is started in anything other than an STA. As far as changes 1.0 to 1.1, there really isn't much besides new methods and a few new classes, and a few methods and properties that are now obsolete - nothing conceptual is mentioned, though. All I can think is to click on the Debug->Exceptions menu and break on all exceptions. Changes are that you'll end up looking at assembler code, but it should give you some stack frame if the debugging symbols are loaded. If you're not using a checked build of Windows, they are probably stripped. VC++ does install some program database (pdb files), but not for the core libraries. If you dig around though, you should at least be able to determine which library you're in. That could help solve the problem since most libraries are pretty specialized.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Many threads are created that handle various things, like painting a control or for asynchronous operations. You never know. Make sure you're compiling a debug build. There's other reasons you might not be able to use some of the debugging tools (threads are always funny when it comes to that), but just to eliminate the obvious I mentioned that. If you think it has something to do with threading, check that your application's
Main
entry point is attributed with theSTAThreadAttribute
, which is the main UI thread. Usually, though, you get different errors if your application is started in anything other than an STA. As far as changes 1.0 to 1.1, there really isn't much besides new methods and a few new classes, and a few methods and properties that are now obsolete - nothing conceptual is mentioned, though. All I can think is to click on the Debug->Exceptions menu and break on all exceptions. Changes are that you'll end up looking at assembler code, but it should give you some stack frame if the debugging symbols are loaded. If you're not using a checked build of Windows, they are probably stripped. VC++ does install some program database (pdb files), but not for the core libraries. If you dig around though, you should at least be able to determine which library you're in. That could help solve the problem since most libraries are pretty specialized.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
OK, thanks for the help. I'll try and see what happens with all exceptions breaking into the debugger on throw.