Error in showdialog of form.

  • Thread starter trialproduct2004
  • Start date
T

trialproduct2004

Hi all
I am new to vb.net application.
I am using showdialog property of form to display form.
First time it is working properly.
But next time it is giving me error that ' object reference not set to
an instance of an object'.

When i went through stacktrace, i found that it is giving error in
showwindow.
I am not getting why it is happening.
Can some one tell me reason behing this.
Please help me.
Thanks in advance.
 
C

Cor Ligthert [MVP]

Trial,

Mostly are this kind of question easy to answer if there is some code.
How do you want us to do it now, you could have done almost everything.

However in this case have you probably set your form globally.

The most simple way is just there where you want to use it to do.

\\\
dim frm1 as new Form2
frm1.showdialog(me)
frm1.dispose
///

This saves you than as well some memory and is as efficient as any other
way.

I hope this helps,

Cor
 
H

Herfried K. Wagner [MVP]

I am using showdialog property of form to display form.
First time it is working properly.
But next time it is giving me error that ' object reference not set to
an instance of an object'.

When i went through stacktrace, i found that it is giving error in
showwindow.
I am not getting why it is happening.

Please post the complete error message + callstack, if available.
 
T

trialproduct2004

Hi.
I am posting stacktrace as below:-
Please check this and tell me solution if u know.

Stack trace.
Object reference not set to an instance of an object. at
System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32
nCmdShow)

at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

at System.Windows.Forms.Control.set_Visible(Boolean value)

at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

at System.Windows.Forms.Form.ShowDialog()

at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)

at System.Windows.Forms.Control.WndProcException(Exception e)

at
System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)

at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

at System.Windows.Forms.Control.set_Visible(Boolean value)

at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

at form1.cDownLoader.DownLoadFile(String sRemotePath, Int64
lFileSize, String
sDate)System.NullReferenceExceptionSystem.NullReferenceException:
Object reference not set to an instance of an object.

at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)

at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

at System.Windows.Forms.Control.set_Visible(Boolean value)

at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

at System.Windows.Forms.Form.ShowDialog()

at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)

at System.Windows.Forms.Control.WndProcException(Exception e)

at
System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)

at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

at System.Windows.Forms.Control.set_Visible(Boolean value)

at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

at form1.cDownLoader.DownLoadFile(String sRemotePath, Int64
lFileSize, String sDate)
 

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