472,328 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 2093
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...
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,...
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...
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...
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...
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...
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....
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...
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.