VB.NET problems displaying custom dialog box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I added a form to my project to use as a dialog box. The form is simple, 2
text boxes, 1 checkbox, 3 labels and 2 buttons. It will eventually allow a
user to reset a password, but I haven't added the functionality yet. I have
the dialog created when the user selects Tools - Reset Password from my main
menu control. When Reset Password is clicked I execute:

Dim frmResetPassword As New ResetPassword
frmResetPassword.ShowDialog()

Where ResetPassword is the name of the new form. When launched it's
generating an error:

Object reference not set to an instance of an object.

The error is generated from an unknown module. Now here is where it gets
weird. If I add a button to the form and run it again I don't get an error.
I don't put code behind the button or change anything else (I still execute
from the menu item), I just add it to the form.

I have no idea what is going on and would be most appreciative to anyone who
can point me to a solution.

Thanks.
 
I would suggest wrapping the ShowDialog call in a try/catch block and
then enumerate through the entire exception chain to see if that gives
any useful information. Here's an example:

Try
frmResetPassword.ShowDialog()
Catch ex As Exception
Dim tmpEx As Exception = ex
While Not tmpEx Is Nothing
Debug.WriteLine(tmpEx.Message & ": " & tmpEx.StackTrace)
tmpEx = tmpEx.InnerException
End While
End Try

At least this might help narrow down what is causing the problem.
 
Back
Top