473,390 Members | 1,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Unhandled Exception (does not look like it's happening within code

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.CallWindo wProc(IntPtr wndProc,
IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& 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(Messag e& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& 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.
Nov 19 '05 #1
4 2216
that is a lot... and I hate to say it but sadly it's the wrong group.
You posted this to an ASP.NET group, not a winforms group....

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Craig831" wrote:
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.CallWindo wProc(IntPtr wndProc,
IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& 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(Messag e& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& 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.

Nov 19 '05 #2
this is the asp.net group and the question is about a winforms application.
when you call application close, an exit message is added to the windows
event queue, and delivered to any control interested in shutdown
notification. you have one that references a null object.

-- bruce (sqlwork.com)

"Craig831" <Cr******@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
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.CallWindo wProc(IntPtr wndProc,
IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& 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(Messag e& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& 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.

Nov 19 '05 #3
Yeah, sorry about that. I realized it after I posted the message. I've
posted it to the dotnet.framework.windowsforms and dotnet.general. I was
brought here from the Microsoft .Net Developer page when I clicked a link
for hot topics.

My apologies for the incorrect post.

On Wed, 14 Sep 2005 09:17:08 -0700, Curt_C[ MVP] wrote:
that is a lot... and I hate to say it but sadly it's the wrong group.
You posted this to an ASP.NET group, not a winforms group....


Nov 19 '05 #4
On Wed, 14 Sep 2005 09:21:22 -0700, Bruce Barker wrote:
this is the asp.net group and the question is about a winforms application.
when you call application close, an exit message is added to the windows
event queue, and delivered to any control interested in shutdown
notification. you have one that references a null object.

-- bruce (sqlwork.com)


Yeah, sorry about that. I realized it after I posted the message. I've
posted it to the dotnet.framework.windowsforms and dotnet.general. I was
brought here from the Microsoft .Net Developer page when I clicked a link
for hot topics.

My apologies for the incorrect post.

Thanks, though, for being the first person to explain to me what is
happening. :)
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paul Steele | last post by:
I often use the following code to check if a program is already running: if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1) ... This works find on all of my...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
4
by: Frank | last post by:
Hi, I made a handler for unhandled errors. But before that is executed, VB.NET gives me the standard error window. In VB6 there was a setting (errortrapping) about handling errors in the design...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
5
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
5
by: Simon Tamman {Uchiha Jax} | last post by:
Now this is bugging me. I just released software for a client and they have reported an unhandled stack overflow exception. My first concern is that the entirity of the UI and any threaded...
132
by: Zorro | last post by:
The simplicity of stack unraveling of C++ is not without defective consequences. The following article points to C++ examples showing the defects. An engineer aware of defects can avoid...
8
by: amyl | last post by:
I have an application whose main function is encapsulated in encased in a try/catch block catching Exception. My application has crashed on several occasions with a CLR exception. CLR exception...
0
by: Autostrad | last post by:
I use V C++ 2008. From the code below I am trying to make a program that will ask the user to enter a number into the text box. If the user click “OK”, without entering a number a dialog box will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.