CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2007
    Posts
    51

    Runtime Error when trying to load a form

    When I hit F5 in Visual Basic.NET 2003 to test the program, it loads just fine. From the main form, I have three buttons, each of which takes users to a different form. Two of the buttons work as intended. One of them has been working, but all of a sudden has given me this error message:

    "An unhandled exception of type "System.InvalidProgramException' occurred in MyProgram.exe

    Additional information: Common Lanaguage Runtime detected an invalid program."

    It then highlights in the Windows Form Designer generated code:

    InitializeComponent()

    Does anyone know how I can fix this? I have no clue what the problem is and I'm a novice with regards to odd runtime errors.

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Runtime Error when trying to load a form

    Not nearly enough information....

    Simply configure VS to break on exception, and look at the line of code that is faulting. Also be sure to pat attention to the exceptions message and inner exception propertied...
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Runtime Error when trying to load a form

    Quote Originally Posted by TheCPUWizard
    Not nearly enough information....
    Well, actually the Exception supplied, is all the info that is needed

    irishman, you may want to look at this MSDN reference :
    http://msdn.microsoft.com/en-us/libr...exception.aspx

    And here's a Search on MSDN :
    http://social.msdn.microsoft.com/Sea...y=Q312544&ac=8

    I hope it helps!
    Last edited by HanneSThEGreaT; October 22nd, 2008 at 12:47 AM.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Runtime Error when trying to load a form

    Quote Originally Posted by HanneSThEGreaT
    Well, actually the Exception supplied, is all the info that is needed ;
    For VS-2003 (aka .Net 1.x) there are a few interesting situations...lets look at the msdn link you provided:

    The exception that is thrown when a program contains invalid Microsoft intermediate language (MSIL) or metadata. Generally this indicates a bug in the compiler that generated the
    The most important word here is generally...It does NOT always indicate a bus in the compiler per se....

    There are also some user generated code situations that can induce this error. Therefore I stand by my original statement, that until we actually see a program that reproduces the error, there is insufficient information.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Runtime Error when trying to load a form

    Yeah well, I don't know everything as you seem to do, as I don't have 35 years experience as you - But I do know what an error means, and how to fix it, or how to find applicable info on an error.

    I also provided the MSDN search link, if you didn't notice, so let's see what that brings up, and hopefully the OP ( irishman ) will get closer to his solution.

  6. #6
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Re: Runtime Error when trying to load a form

    Irishman

    I've had the same error in the past and for me (thankfully) all it took was a rebuild and it was sorted!
    Visual Basic 2005 ver. 8.0.50727.867

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured