weird error upon form loading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iwdu15

    weird error upon form loading

    hi, i have a few forms in my project. when i load form1 (startup for) all is
    fine, then i open another one and use a login screen to call yet another and
    all is still fine, but then when i try to open another form from a 3rd form,
    it gives this error on form1

    "An unhandled exception of type 'System.NullRef erenceException ' occurred in
    Unknown Module.

    Additional information: Object reference not set to an instance of an object."

    yet the form has opened, but then the program just crashes...

    heres how i open the form:

    Dim frm As New OldBrackets
    Close()
    frm.Show()

    im puzzled so any help is awsome
  • Chris

    #2
    Re: weird error upon form loading

    iwdu15 wrote:[color=blue]
    > hi, i have a few forms in my project. when i load form1 (startup for) all is
    > fine, then i open another one and use a login screen to call yet another and
    > all is still fine, but then when i try to open another form from a 3rd form,
    > it gives this error on form1
    >
    > "An unhandled exception of type 'System.NullRef erenceException ' occurred in
    > Unknown Module.
    >
    > Additional information: Object reference not set to an instance of an object."
    >
    > yet the form has opened, but then the program just crashes...
    >
    > heres how i open the form:
    >
    > Dim frm As New OldBrackets
    > Close()
    > frm.Show()
    >
    > im puzzled so any help is awsome[/color]


    I think this is what is happening....

    Dim frm As New OldBrackets <- Create a new form store it in frm
    Close() <- Close current form and all it's variables including frm
    frm.Show() <- frm has been released, now you get your error.

    Maybe try:
    Dim frm As New OldBrackets
    frm.Show()
    Close()

    Comment

    • Armin Zingler

      #3
      Re: weird error upon form loading

      "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb[color=blue]
      > hi, i have a few forms in my project. when i load form1 (startup
      > for) all is fine, then i open another one and use a login screen to
      > call yet another and all is still fine, but then when i try to open
      > another form from a 3rd form, it gives this error on form1
      >
      > "An unhandled exception of type 'System.NullRef erenceException '
      > occurred in Unknown Module.
      >
      > Additional information: Object reference not set to an instance of
      > an object."
      >
      > yet the form has opened, but then the program just crashes...
      >
      > heres how i open the form:
      >
      > Dim frm As New OldBrackets
      > Close()
      > frm.Show()
      >
      > im puzzled so any help is awsome[/color]


      What is the line throwing the error? Please post the callstack when the
      error occurs (menu debug -> windows -> callstack).


      Armin

      Comment

      • Armin Zingler

        #4
        Re: weird error upon form loading

        "Chris" <no@spam.com> schrieb[color=blue]
        > iwdu15 wrote:[color=green]
        > > hi, i have a few forms in my project. when i load form1 (startup
        > > for) all is fine, then i open another one and use a login screen
        > > to call yet another and all is still fine, but then when i try to
        > > open another form from a 3rd form, it gives this error on form1
        > >
        > > "An unhandled exception of type 'System.NullRef erenceException '
        > > occurred in Unknown Module.
        > >
        > > Additional information: Object reference not set to an instance of
        > > an object."
        > >
        > > yet the form has opened, but then the program just crashes...
        > >
        > > heres how i open the form:
        > >
        > > Dim frm As New OldBrackets
        > > Close()
        > > frm.Show()
        > >
        > > im puzzled so any help is awsome[/color]
        >
        >
        > I think this is what is happening....
        >
        > Dim frm As New OldBrackets <- Create a new form store it in frm
        > Close() <- Close current form and all it's variables including frm
        > frm.Show() <- frm has been released, now you get your error.[/color]


        This is not right. Close closes the form, i.e. the corresponding window,
        nothing else. frm is a local variable and still holds a reference to the new
        Form, thus frm is not Nothing after closing the form and frm.show can not
        throw the exception - maybe within one of the sub procedures but not because
        frm is nothing.


        Armin

        [color=blue]
        > Maybe try:
        > Dim frm As New OldBrackets
        > frm.Show()
        > Close()
        >[/color]

        Comment

        • iwdu15

          #5
          Re: weird error upon form loading

          this is gunna throw all you guys for a loop....it shows an error, highlighted
          in green on this line:

          Public Class Form1

          this has got me stumped, i have a few imports so maybe its with one of them,
          although i dont get any errors on them, but here they are anyway

          Imports System.Runtime. InteropServices
          Imports System.Drawing
          Imports System.Drawing. Drawing2D
          Imports MsdnMag

          so anyone that can help id be grateful

          Comment

          • iwdu15

            #6
            Re: weird error upon form loading

            i thought it might be an error with the gererated code so i made a new form
            and copyied all the code (besides the windows designer code) to the new form
            and remade the second form to be exactly like the first but it gsave the
            error on the new form also

            Comment

            • Armin Zingler

              #7
              Re: weird error upon form loading

              "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb[color=blue]
              > i thought it might be an error with the gererated code so i made a
              > new form and copyied all the code (besides the windows designer
              > code) to the new form and remade the second form to be exactly like
              > the first but it gsave the error on the new form also[/color]


              Without posting the callstack as suggested, I am not able to help you.


              Armin

              Comment

              • iwdu15

                #8
                Re: weird error upon form loading

                sorry, my bad, heres what i copied from the call stack
                [color=blue]
                > Brackets.exe!Br ackets.Main.Mai n() Line 6 + 0x1d bytes Basic[/color]

                Comment

                • Armin Zingler

                  #9
                  Re: weird error upon form loading

                  "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb[color=blue]
                  > sorry, my bad, heres what i copied from the call stack
                  >[color=green]
                  > > Brackets.exe!Br ackets.Main.Mai n() Line 6 + 0x1d bytes Basic[/color]
                  >[/color]

                  This is the complete callstack? Well, possible. I wonder why the error
                  occurs there because you write it doesn't happen before you open another
                  form.

                  What if you add this sub to your startup form:

                  shared sub main
                  dim f as new form1 'assuming form1 is the startup form
                  application.run (f)
                  end sub

                  Where does the error occur now, and what does the callstack say?

                  More questions: Are you working with threads? Do you have shared members in
                  your startup Form?


                  Armin

                  Comment

                  • iwdu15

                    #10
                    Re: weird error upon form loading

                    when i did the shared sub main thing, it still happened and the call stack
                    was empty, as for threads....id ont think im using them...im guessing if i
                    dont kno them im prob not, so the same for shared members...and for my
                    startup form, all it does is load settings from an ini file, which has worked
                    since i started this project, save settings, and open new forms based on
                    button clicks. but when i open a certain form, which doesnt have a formload
                    event, it crashes, if u need more source code just tell me

                    Comment

                    • iwdu15

                      #11
                      Re: weird error upon form loading

                      ok well another weird thing, when i made the form (the one that when it
                      loads, gives an error on another form) the startup form, all was well and good

                      Comment

                      • Armin Zingler

                        #12
                        Re: weird error upon form loading

                        "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb[color=blue]
                        > when i did the shared sub main thing, it still happened and the call
                        > stack was empty, as for threads....[/color]


                        Did you pause (ctrl+break) the program? There must be something in the
                        callstack.
                        [color=blue]
                        > id ont think im using them...im
                        > guessing if i dont kno them im prob not, so the same for shared
                        > members...and for my startup form, all it does is load settings from
                        > an ini file, which has worked since i started this project, save
                        > settings, and open new forms based on button clicks. but when i open
                        > a certain form, which doesnt have a formload event, it crashes, if u
                        > need more source code just tell me[/color]


                        If it's possible to send me the whole project (zipped, please), send it to
                        az.nospam@freen et.de but insert an underscore between "no" and "spam" in the
                        address before.


                        Armin

                        Comment

                        • iwdu15

                          #13
                          Re: weird error upon form loading

                          sent, and thanks a ton

                          Comment

                          • Armin Zingler

                            #14
                            Re: weird error upon form loading

                            "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb[color=blue]
                            > sent, and thanks a ton[/color]

                            Hew.. pretty big project... I'll have a look. :-)


                            Armin

                            Comment

                            • Armin Zingler

                              #15
                              Re: weird error upon form loading

                              "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb[color=blue]
                              > hi, i have a few forms in my project. when i load form1 (startup
                              > for) all is fine, then i open another one and use a login screen to
                              > call yet another and all is still fine, but then when i try to open
                              > another form from a 3rd form, it gives this error on form1
                              >
                              > "An unhandled exception of type 'System.NullRef erenceException '
                              > occurred in Unknown Module.
                              >
                              > Additional information: Object reference not set to an instance of
                              > an object."
                              >
                              > yet the form has opened, but then the program just crashes...
                              >
                              > heres how i open the form:
                              >
                              > Dim frm As New OldBrackets
                              > Close()
                              > frm.Show()
                              >
                              > im puzzled so any help is awsome[/color]


                              After he sent the project to me, it turned out to be the following problem:



                              Easiest way to reproduce the problem is to add a combobox (add some items)
                              in a new empty project and call Me.Close in it's selectedindexch anged event.

                              I didn't have a solution. Anybody?


                              Armin

                              Comment

                              Working...