Results 1 to 4 of 4

Thread: C# Problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    C# Problem

    My App was running OK. But i am getting this error when i try tro run it.

    An unhandled exception of type 'System.NullReferenceException' occurred in
    system.windows.forms.dll

    This is the code
    static void Main()
    {
    Application.Run(new MainForm());
    }

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: C# Problem

    I doubt that this is actually the code that is throwing the exception. Assuming that there is no bug with VS, I would guess that execution is entering the MainForm constructor and your exception is being thrown somewhere in there. Try this code:
    VB Code:
    1. try
    2. {
    3.     Application.Run(new MainForm());
    4. }
    5. catch (Exception ex)
    6. {
    7.     MessageBox.Show(ex.ToString());
    8. }
    When the exception is thrown you should get a message box that shows a call stack to the point where the exception occurred. This may help you to narrow it down.

  3. #3
    Lively Member skv_noida's Avatar
    Join Date
    May 2005
    Location
    Noida, India
    Posts
    76

    Re: C# Problem

    Ya Try to Get more clear Message...........




  4. #4
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: C# Problem

    post your code for the forms Load() event...i've seen this happen in one of my programs...at load, a database connection wasnt getting made and got the same error...damn network guys LOL

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