By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,496 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,496 IT Pros & Developers. It's quick & easy.

weird error upon form loading

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
iwdu15 wrote:
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()

Nov 21 '05 #2

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> schrieb
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

Nov 21 '05 #3

P: n/a
"Chris" <no@spam.com> schrieb
iwdu15 wrote:
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.

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

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


Nov 21 '05 #4

P: n/a
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
Nov 21 '05 #5

P: n/a
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
Nov 21 '05 #6

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> schrieb
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
Nov 21 '05 #7

P: n/a
sorry, my bad, heres what i copied from the call stack
Brackets.exe!Brackets.Main.Main() Line 6 + 0x1d bytes Basic


Nov 21 '05 #8

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> schrieb
sorry, my bad, heres what i copied from the call stack
Brackets.exe!Brackets.Main.Main() Line 6 + 0x1d bytes Basic


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

Nov 21 '05 #9

P: n/a
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
Nov 21 '05 #10

P: n/a
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
Nov 21 '05 #11

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> schrieb
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
az*******@freenet.de but insert an underscore between "no" and "spam" in the
address before.
Armin

Nov 21 '05 #12

P: n/a
sent, and thanks a ton
Nov 21 '05 #13

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> schrieb
sent, and thanks a ton


Hew.. pretty big project... I'll have a look. :-)
Armin
Nov 21 '05 #14

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> schrieb
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_q...ublic.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

Nov 21 '05 #15

P: n/a
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
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.
Nov 21 '05 #16

P: n/a
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
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/...3a6f2179bfd945
Armin

Nov 21 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.