Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Strange exception in a strange thread

Strange exception in a strange thread

Scheduled Pinned Locked Moved C#
csharpvisual-studiodesigndata-structuresquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Broken God
    wrote on last edited by
    #1

    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.

    H 1 Reply Last reply
    0
    • B Broken God

      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.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 the STAThreadAttribute, 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-----

      B 1 Reply Last reply
      0
      • H Heath Stewart

        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 the STAThreadAttribute, 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-----

        B Offline
        B Offline
        Broken God
        wrote on last edited by
        #3

        OK, thanks for the help. I'll try and see what happens with all exceptions breaking into the debugger on throw.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups