473,851 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Exi t, 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.EventArg s) Handles btnFinish.Click
Dim frmDemog As New frmDemographics

frmMain.GroupCo unt += 1
If frmMain.GroupLi st(frmMain.Grou pCount) <> "" Then
Try
frmMain.GroupSe lect = frmMain.GroupLi st(frmMain.Grou pCount)
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.Cr Lf & "Source: " & eException.Sour ce _
& ControlChars.Cr Lf & "Descriptio n: " &
eException.Mess age, "Group Extractor")
End Try
Else
Try
MsgBox("Your export files are located in " & sLocation,
MsgBoxStyle.OKO nly, "No More Clients")
Application.Exi t()
Catch eExcept As Exception
MessageBox.Show ("Exception has occurred: " &
ControlChars.Cr Lf & "Source: " & eExcept.Source _
& ControlChars.Cr Lf & "Descriptio n: " & 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.NullRef erenceException ' 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 CustomException Handler 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.UnsafeNat iveMethods.Call WindowProc(IntP tr wndProc,
IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Control.D efWndProc(Messa ge& m)
at System.Windows. Forms.Control.W mDestroy(Messag e& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.DateTimeP icker.WndProc(M essage& m)
at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr 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 CustomException Handler),
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 2961
> I've also added CustomException Handler 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.DateTimeP icker.WndProc(M essage& 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 mainFormReferen ce As frmMain
Dim demoFormReferen ce As frmDemographics

----

Then in the form frmMain, when creating a new frmQuestions

---

Dim frmQuestion As New frmQuestions()
frmQuestion.mai nFormReference = Me
frmQuestion.Sho w()

---

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
536
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 system.windows.forms.dll. Additional information: Object reference not set to an instance of an object. Visual Studio's IDE is not allowing me to develop projects in C#... I've trying to create a simple Windows Forms project using Visual Studio.NET...
3
1661
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 totally random as to if and when they occur. if have not been able to reproduce these errors on my machine nor can anyone else here in the IT dept. i have try catch blocks around every event, sub, and function involved in the process (even in the...
4
5519
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 a timeout less than the time required to process the code section it protects. The code listed below is just a small application I wrote to check the behavious of the different threading / synchronization techniques. Basically the application...
4
2257
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 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...
5
5757
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 thread.Abort()) is reported twice: once in the debug window, and once through the message box. Is it because the thread was sleeping when the exception occurred?
3
276
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 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...
5
3408
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 operations are all within Try Catches to help me locate the problem and the origination of any problem by specifiying an error code in the "Catch" section. So theoretically this shouldn't have been possible (at which point we all say "yeah,...
0
1468
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 resulting MSI explicitly installs the service. I've ran the installer on 4 machines at our office (2 are running Windows 2000 Pro, 1 is running XP Pro, and the other is running Windows 98). On each of these machines, the installation goes without a...
5
2101
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 test it, runs no problem. When I compile and release the dll, the user gets an unhandled exception. It doesn't halt the code, it just shows an error dialog...click continue and it continues. Is there some setting I must set so that I can see...
0
9897
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9747
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11019
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10728
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9506
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7906
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5736
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.