weird error upon form loading

G

Guest

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.NullReferenceException' 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
 
C

Chris

iwdu15 said:
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.NullReferenceException' 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


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()
 
A

Armin Zingler

iwdu15 said:
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.NullReferenceException'
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


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


Armin
 
A

Armin Zingler

Chris said:
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.


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
 
G

Guest

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
 
G

Guest

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
 
A

Armin Zingler

iwdu15 said:
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


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


Armin
 
A

Armin Zingler

iwdu15 said:
sorry, my bad, heres what i copied from the call stack

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
 
G

Guest

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
 
G

Guest

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
 
A

Armin Zingler

iwdu15 said:
when i did the shared sub main thing, it still happened and the call
stack was empty, as for threads....


Did you pause (ctrl+break) the program? There must be something in the
callstack.
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


If it's possible to send me the whole project (zipped, please), send it to
(e-mail address removed) but insert an underscore between "no" and "spam" in the
address before.


Armin
 
A

Armin Zingler

iwdu15 said:
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.NullReferenceException'
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


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

http://groups.google.com/groups?as_...exception&as_ugroup=microsoft.public.dotnet.*

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 selectedindexchanged event.

I didn't have a solution. Anybody?


Armin
 
P

Phill. W

iwdu15 said:
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

To forget to tell us the actual error message you are getting /once/ might
be construed as an oversight; to do so twice seems like you're
just trying to be annoying.

What is [the complete wording of] the Error that you are getting???

Regards,
Phill W.
 
A

Armin Zingler

Phill. W said:
iwdu15 said:
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

To forget to tell us the actual error message you are getting /once/
might be construed as an oversight; to do so twice seems like you're
just trying to be annoying.

What is [the complete wording of] the Error that you are getting???


Maybe you didn't read the whole thread: He mailed the project to me, and
after I found the cause of the error I posted it here also in the case
somebody might have a solution:

http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/msg/853a6f2179bfd945


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top