P
Professor Frink
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on this
application for about a month and it was working flawlessly until last
Thursday. Basically, over the last week, I've been tweaking the interface
but the base functionality had been working without issue for about a week
and a half before I started seeing this problem.
The application has three forms (frmMain - 2 listboxes, 1 combobox, 4
command buttons, menu, frmDemographics - many textboxes and labels, 2 radio
buttons, 3 command buttons, frmQuestions - textboxes, labels, two radio
buttons, 1 multi-line textbox). The application starts with frmMain where
the user enters an e-mail address, then chooses a data region with the
combobox. After choosing their region, they hit the populate button which
populates one of the listboxes. I'm retrieving the data using a data reader
tied to an ODBC driver which allows me to access VSAM data using SQL. The
user, after the listbox is filled with all clients from the selected region,
selects on or more clients to export. As they double-click or highlight and
move a client, the client is moved to a second listbox. When they are happy
with the clients they've selected, they hit the export button.
The click event of the export button builds a public shared string array of
the selected clients (must have a minimum of 1 and has a maximum of 250),
hides frmMain, then shows frmDemographics. frmDemographics displays
demographic information for the client which the user must verify. If they
agree with what they see, then click the "agree" radio button which enables
the "next" button. When they click "next", the click even hides
frmDemographic and shows frmQuestions.
On frmQuestions, the user is required to enter a web site address, answer a
couple questions via radio buttons, and set a couple dates (datetimepicker).
Once they do this, they hit an "export" button, which, using client and plan
year information, uses data readers for multiple types of client record and
builds an output file for the client being processed. As each record is
written to the file, a message is displayed in the multi-line text box,
showing which record was written. After all records are written, a "finish"
button is displayed and the user is told, in the multi-line textbox, to hit
finish to continue.
If all the clients are processed, the click event of the "finish" button
will exit the application. If all clients are not processed, the array
counter will increment so the next group is being processed, then it will
hide frmQuestions and instantiate and show a new frmDemographics. The
application will continue swapping between these two forms until all clients
are processed.
Now that you have the logic of the application, here's the problem. I've
traced the code, line by line, and this problem occurs after the Sub has
finished processing. Sometimes it happens after Application.Exit, sometimes
it happens after frmDemog.Show, and sometimes it doesn't happen at all.
Here's the code that runs right before the error:
Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFinish.Click
Dim frmDemog As New frmDemographics
frmMain.GroupCount += 1
If frmMain.GroupList(frmMain.GroupCount) <> "" Then
Try
frmMain.GroupSelect = frmMain.GroupList(frmMain.GroupCount)
frmDemographics.PLYExists = True
DIVExists = True
IBCExists = True
PAYExists = True
DISExists = True
BNKExists = True
ADRExists = True
Me.Hide()
frmDemog.Show()
Catch eException As Exception
MessageBox.Show("Exception has occurred: " &
ControlChars.CrLf & "Source: " & eException.Source _
& ControlChars.CrLf & "Description: " &
eException.Message, "Group Extractor")
End Try
Else
Try
MsgBox("Your export files are located in " & sLocation,
MsgBoxStyle.OKOnly, "No More Clients")
Application.Exit()
Catch eExcept As Exception
MessageBox.Show("Exception has occurred: " &
ControlChars.CrLf & "Source: " & eExcept.Source _
& ControlChars.CrLf & "Description: " & eExcept.Message,
"Group Extractor")
End Try
End If
End Sub <--- Error always seems to happen after this line of code has
finished processing. The application processes this line of code before the
exeption EVERY time. Even if the application is trying to exit, and no more
code is processed, I will get the error after this line of code. I can't
lock down a pattern to the exception.
The exception is:
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
I've been working on this since Thursday morning, like I said, and have
searched and searched all over the place. I've looked through my MSDN
documentation, searched google until my fingers are falling off, searched the
Microsoft Knowledge Base multiple times, and posted this same post on VBCity.
One of the leaders on VBCity has been very helpful but he keeps telling me I
have an error in my code, which doesn't compute with me. If the error was in
my code, wouldn't the error have a pattern and wouldn't it happen on other
machines?
I've also added CustomExceptionHandler class to all the forms in an effort
to capture the exception and have only been able to capture it twice. I
still get the unhandled exception sometimes, with no explanation, but when I
do get the exception handler to capture the exception, this is what I get:
An error occurred please contact the administrator with the following
information:
Object reference not set to an instance of an object.
Stack Trace:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc,
IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmDestroy(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
Again, please accept my apology for the length of this post. Just trying to
get you all the information. I've been pulling my hair out for six days and
can't figure out what the heck is going on. If there was a pattern to the
exception, I could find it and fix it. Problem is, it happens sometimes and
doesn't happen other times. Also, when I've sent the application to other
developers on my team (the ones that helped with the CustomExceptionHandler),
they don't get the error. The application runs flawlessly on their machines.
Thank you to anyone who can help me out with this.
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on this
application for about a month and it was working flawlessly until last
Thursday. Basically, over the last week, I've been tweaking the interface
but the base functionality had been working without issue for about a week
and a half before I started seeing this problem.
The application has three forms (frmMain - 2 listboxes, 1 combobox, 4
command buttons, menu, frmDemographics - many textboxes and labels, 2 radio
buttons, 3 command buttons, frmQuestions - textboxes, labels, two radio
buttons, 1 multi-line textbox). The application starts with frmMain where
the user enters an e-mail address, then chooses a data region with the
combobox. After choosing their region, they hit the populate button which
populates one of the listboxes. I'm retrieving the data using a data reader
tied to an ODBC driver which allows me to access VSAM data using SQL. The
user, after the listbox is filled with all clients from the selected region,
selects on or more clients to export. As they double-click or highlight and
move a client, the client is moved to a second listbox. When they are happy
with the clients they've selected, they hit the export button.
The click event of the export button builds a public shared string array of
the selected clients (must have a minimum of 1 and has a maximum of 250),
hides frmMain, then shows frmDemographics. frmDemographics displays
demographic information for the client which the user must verify. If they
agree with what they see, then click the "agree" radio button which enables
the "next" button. When they click "next", the click even hides
frmDemographic and shows frmQuestions.
On frmQuestions, the user is required to enter a web site address, answer a
couple questions via radio buttons, and set a couple dates (datetimepicker).
Once they do this, they hit an "export" button, which, using client and plan
year information, uses data readers for multiple types of client record and
builds an output file for the client being processed. As each record is
written to the file, a message is displayed in the multi-line text box,
showing which record was written. After all records are written, a "finish"
button is displayed and the user is told, in the multi-line textbox, to hit
finish to continue.
If all the clients are processed, the click event of the "finish" button
will exit the application. If all clients are not processed, the array
counter will increment so the next group is being processed, then it will
hide frmQuestions and instantiate and show a new frmDemographics. The
application will continue swapping between these two forms until all clients
are processed.
Now that you have the logic of the application, here's the problem. I've
traced the code, line by line, and this problem occurs after the Sub has
finished processing. Sometimes it happens after Application.Exit, sometimes
it happens after frmDemog.Show, and sometimes it doesn't happen at all.
Here's the code that runs right before the error:
Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFinish.Click
Dim frmDemog As New frmDemographics
frmMain.GroupCount += 1
If frmMain.GroupList(frmMain.GroupCount) <> "" Then
Try
frmMain.GroupSelect = frmMain.GroupList(frmMain.GroupCount)
frmDemographics.PLYExists = True
DIVExists = True
IBCExists = True
PAYExists = True
DISExists = True
BNKExists = True
ADRExists = True
Me.Hide()
frmDemog.Show()
Catch eException As Exception
MessageBox.Show("Exception has occurred: " &
ControlChars.CrLf & "Source: " & eException.Source _
& ControlChars.CrLf & "Description: " &
eException.Message, "Group Extractor")
End Try
Else
Try
MsgBox("Your export files are located in " & sLocation,
MsgBoxStyle.OKOnly, "No More Clients")
Application.Exit()
Catch eExcept As Exception
MessageBox.Show("Exception has occurred: " &
ControlChars.CrLf & "Source: " & eExcept.Source _
& ControlChars.CrLf & "Description: " & eExcept.Message,
"Group Extractor")
End Try
End If
End Sub <--- Error always seems to happen after this line of code has
finished processing. The application processes this line of code before the
exeption EVERY time. Even if the application is trying to exit, and no more
code is processed, I will get the error after this line of code. I can't
lock down a pattern to the exception.
The exception is:
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
I've been working on this since Thursday morning, like I said, and have
searched and searched all over the place. I've looked through my MSDN
documentation, searched google until my fingers are falling off, searched the
Microsoft Knowledge Base multiple times, and posted this same post on VBCity.
One of the leaders on VBCity has been very helpful but he keeps telling me I
have an error in my code, which doesn't compute with me. If the error was in
my code, wouldn't the error have a pattern and wouldn't it happen on other
machines?
I've also added CustomExceptionHandler class to all the forms in an effort
to capture the exception and have only been able to capture it twice. I
still get the unhandled exception sometimes, with no explanation, but when I
do get the exception handler to capture the exception, this is what I get:
An error occurred please contact the administrator with the following
information:
Object reference not set to an instance of an object.
Stack Trace:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc,
IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmDestroy(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
Again, please accept my apology for the length of this post. Just trying to
get you all the information. I've been pulling my hair out for six days and
can't figure out what the heck is going on. If there was a pattern to the
exception, I could find it and fix it. Problem is, it happens sometimes and
doesn't happen other times. Also, when I've sent the application to other
developers on my team (the ones that helped with the CustomExceptionHandler),
they don't get the error. The application runs flawlessly on their machines.
Thank you to anyone who can help me out with this.