473,507 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding Null Refernce error

Can someone please advise me how I can track down where the error that
causes the following error message to appear is located in my code
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.

The error occurs when I am testing port settings by selecting a valid serial
port then invalid port then valid port again.
The code handling this port selection writes to a log each time the port is
attempted to be opened. I suspect that the StreamWriter CLOSE method takes
time and the routine is being called again before the file is physically
closed on the disk.

Could this be an issue ? If so, w\how would I test the file is closed before
the code continues
Whether this is the actual issue in this instance, is there a way I can find
out which object is being refrred to in the error dialog ?

Thanks in advance
Nov 21 '05 #1
1 928
Wrap your code in a Try Catch block and then print out the stack trace.
It will tell you which line the exception is occurring on.

Try
'Code here
Catch ex as NullReferenceException
MsgBox(ex.StackTrace)
End Try

Nov 21 '05 #2

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

Similar topics

1
1288
by: asp.net NUT!!! | last post by:
Hi I've been trying to add a web refernece to a asp.net application project, from a web service within the same solution. The site is hosted on my local host & in a virtual directory. when I go...
2
2961
by: C L Humphreys | last post by:
Hi, Using a soundex function that works with anything except an empty/null string the following gives me an error part way through the results select surname, soundex(surname) from pd where...
1
1284
by: John M | last post by:
hi, I'm finding this problem most frustrating. (It's probably my lack of undersating of functions!) I want to fill a control in a report with the result of a function. I'm calculating the...
15
46440
by: cwsullivan | last post by:
Hi gang, I have a grid full of particles in my program, and I want to find an angle between two particles. I'm having trouble because it seems like the answer depends on whether or not the target...
2
1989
by: Extremest | last post by:
Here is the code I have so far. It connects to a db and grabs headers. It then sorts them into groups and then puts all the complete ones into another table. Problem I am having is that for some...
6
2106
by: Jim H | last post by:
Pid.DBMil lMil = null; if (null == lMil) System.Diagnostics.Trace.WriteLine("\r\nIt was NULL\r\n"); //-- this never prints That diag line never prints. later on in a loop I do this: for...
3
1036
by: sahilu | last post by:
hi to all, i want the sol immediately i designed loginpage i gave username, password and register button i have given database connection ,in that login table is there with fields as i click...
6
1980
by: ma740988 | last post by:
Given the snippet. class foo { public: ~foo() { // type id should be able to get the type of the class ( I think ) std::cout << " foo destructing " << std::endl; } };
1
1232
by: moizpalitanawala | last post by:
Hello Friends The code below has no error at compile time. But while executing, it does not show the icon at the left hand top corner of the frame, where a java cup icon is originally shown. I...
0
7223
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
7111
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
7319
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
7376
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
7485
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...
1
5042
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...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.