473,407 Members | 2,320 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,407 software developers and data experts.

Unhandled Exception (no pattern i can find)

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.
Sep 14 '05 #1
3 2916
> 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:
How does your app start up? Is the startup object for the project set
to a form? If so, you might try starting your app using a Sub Main and
then put an exception handler around the code in Sub Main. That might
let you capture the exception more consistently.
Object reference not set to an instance of an object.

Stack Trace:
at System.Windows.Forms.DateTimePicker.WndProc(Messag e& m)


This part of the stack trace seems to indicate the problem has
something to do with the date time pickers. Is it possible that you
are trying to manipuate those controls before they are created (in
form_load for example)? Or after they have been disposed or released?

Just some random thoughts

Sep 14 '05 #2
Forms do not automatically know about each other, why it would work to
begin with, I am not sure - unless you are using a startup vb Main
method that creates the forms and manages their accessability.

To make this work each form class should have a public variable of the
other two form classes

----

' In frmQuestions
Dim mainFormReference As frmMain
Dim demoFormReference As frmDemographics

----

Then in the form frmMain, when creating a new frmQuestions

---

Dim frmQuestion As New frmQuestions()
frmQuestion.mainFormReference = Me
frmQuestion.Show()

---

Sep 14 '05 #3
On Wed, 14 Sep 2005 11:04:17 -0700, Chris Dunaway wrote:
This part of the stack trace seems to indicate the problem has
something to do with the date time pickers. Is it possible that you
are trying to manipuate those controls before they are created (in
form_load for example)? Or after they have been disposed or released?

Just some random thoughts


Thanks for the help. I think you may have pointed me to the problem, but
I'm not sure.

The application, until today, was starting in sub main on
frmmain. It would then hide frmmain and show frmdemographics, then hide
frmdemographics and show frmquestions. It would then loop between
frmdemographics and frmquestions for however many clients needed to be
processed. I did it this way because each form had public shared
variabled that were needed by other forms. I'm relatively new to VB so
maybe I didn't need to do this.

Anyway, I have now put all the public shared variables on frmMain since it
is only instantiated a single time and stays hidden, but in memory, for
the length of each run. I then changed any me.hide command for
frmdemographics and frmquestions to me.close. I've run the application
multiple times today and haven't gotten the exception a single time.

Thanks for the replies, both of you. I appreciate you taking the time to
help out a noob to VB... :)
Sep 15 '05 #4

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

Similar topics

1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
3
by: Kunkel | last post by:
i am using VS.NET 2003 and coding in VB.NET. some of my users recieving an unhandled exception in one of my programs. although these exceptions always occur during a certain process, they are...
4
by: Anders Borum | last post by:
Hello! I am working on improving my threading skills and came across a question. When working with the ReaderWriterLock class, I am getting an unhandled exception if I acquire a WriterLock with...
4
by: Craig831 | last post by:
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...
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...
3
by: Professor Frink | last post by:
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...
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...
0
by: Mike S | last post by:
I'm still looking into this problem, but to summarize: I wrote a very simple Windows Service in VB.NET, as part of a larger application. I created a deployment project for the application the...
5
by: Tim Zych | last post by:
What factor would allow an unhandled exception to occur in a compiled project, versus no error for the same action during development? In other words, I have a project that, in development when I...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.