none
Type Initializer exception only in .exe RRS feed

  • Question

  • Exception Message happens when my splash screen shows: The type initializer for 'App_Name.GlobalThings' threw an exception

    GlobalThings is not a class, but just a module name (Module Globalthings).  I get the error above at run time (.exe) but not during debug.

    Because I am brand new not only to visual studio and to visual basic, but also to programming, I have no idea how to figure out what is actually throwing this error since it occurs only at run time.  From reading other threads I can tell that there is an inner exception that would give me more targeted feedback but I don't know how to get to it.

    How should i go about investigating?

    -Patrick

    Friday, November 18, 2011 6:01 AM

Answers

  • To any newbie who like me had no idea how to delve deeper into the type initialization exception.

     

    I used the application events (Application Settings -> Application tab -> View Application Events) module to write a procedure that Handles Me.UnhandledException.   The procedure is fired whenever the application has an unhandled exception in run mode.

    Within the procedure, I output a messageBox that shows the exception (e.Exception.Message) to determine that it was a type initialization exception, and that also shows the inner exception (e.Exception.InnerException.Message) that told gave me more specific feedback about what was wrong.

    I still don't know how to solve my problem, but at least now I think I know what it is.  Since it has nothing to do with type initialization, I've put it on another thread: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/288fc6e5-a090-4250-a2fc-49192fd0687f

     

    thanks Cor for replying when others just read and moved on.

    -Patrick

    • Marked as answer by ted118 Sunday, November 20, 2011 6:27 AM
    Friday, November 18, 2011 7:52 PM

All replies

  • Put in top of the module

    Option Strict on, or better set that with Tools as standard option for Visual Basic.

     


    Success
    Cor
    Friday, November 18, 2011 7:33 AM
  • Thanks as always Cor.  I turned it on and now a ton of errors show up.  I'll work through them and see whether that fixes things.  It will take me a while though.

     

    Would you please explain quickly why Option Strict Off raised no problem in debug but would cause a type initializer exception in run?  I'd love to understand what you think is going on.

     

    Thanks,

    -Patrick

    Friday, November 18, 2011 3:40 PM
  • I turned on Option Strict in the module that threw the exception and nothing changed.

    In debug mode, i can run the application ok.  In .exe after deployment, I get the same error as in my first post (The type initializer for 'App_Name.GlobalThings' threw an exception).  I still don't know what is causing the problem or how to go about investigating it.

    Any ideas?

    -Patrick

    Friday, November 18, 2011 4:26 PM
  • To any newbie who like me had no idea how to delve deeper into the type initialization exception.

     

    I used the application events (Application Settings -> Application tab -> View Application Events) module to write a procedure that Handles Me.UnhandledException.   The procedure is fired whenever the application has an unhandled exception in run mode.

    Within the procedure, I output a messageBox that shows the exception (e.Exception.Message) to determine that it was a type initialization exception, and that also shows the inner exception (e.Exception.InnerException.Message) that told gave me more specific feedback about what was wrong.

    I still don't know how to solve my problem, but at least now I think I know what it is.  Since it has nothing to do with type initialization, I've put it on another thread: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/288fc6e5-a090-4250-a2fc-49192fd0687f

     

    thanks Cor for replying when others just read and moved on.

    -Patrick

    • Marked as answer by ted118 Sunday, November 20, 2011 6:27 AM
    Friday, November 18, 2011 7:52 PM
  • Hi ted118 a.k.a. Patrick,

    I see you have found the cause of your error in your other thread at.>>

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/288fc6e5-a090-4250-a2fc-49192fd0687f

     

    You could therefore mark this post as an answer, if you wish, in order to point other forum users in the right direction.

     

    Alternatively, to any moderator, do you wish to merge the two threads?




    Regards,

    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.

    Saturday, November 19, 2011 1:40 PM