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

Question on unhandled exceptions

Hello,

I added this event to handle unhandled exceptions:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(UnhandledException) ;

Recently one occured and added the following to my log file:

UnhandledException, Exception='System.IO.IOException: An unexpected network
error occurred.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite()
at System.IO.FileStream.Flush()
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.FileStream.Finalize()' (Loader.UnhandledException)

I see the stack trace starts at Loader.UnhandledException, which is the
event handler I added. However, all I do there is display an error dialog
and log the ExceptionObject. Does this mean the unhandled error did not
originate from within my app? If that is not the case, why can't I see a
more detailed stack trace, indicating from where the error originated?

Thanks.
Sep 15 '06 #1
4 3053
Hi,

Try looking at the InnerException.

--
Dave Sexton

"Flack" <Fl***@discussions.microsoft.comwrote in message news:17**********************************@microsof t.com...
Hello,

I added this event to handle unhandled exceptions:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(UnhandledException) ;

Recently one occured and added the following to my log file:

UnhandledException, Exception='System.IO.IOException: An unexpected network
error occurred.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite()
at System.IO.FileStream.Flush()
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.FileStream.Finalize()' (Loader.UnhandledException)

I see the stack trace starts at Loader.UnhandledException, which is the
event handler I added. However, all I do there is display an error dialog
and log the ExceptionObject. Does this mean the unhandled error did not
originate from within my app? If that is not the case, why can't I see a
more detailed stack trace, indicating from where the error originated?

Thanks.

Sep 15 '06 #2

Flack wrote:
Hello,

I added this event to handle unhandled exceptions:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(UnhandledException) ;

Recently one occured and added the following to my log file:

UnhandledException, Exception='System.IO.IOException: An unexpected network
error occurred.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite()
at System.IO.FileStream.Flush()
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.FileStream.Finalize()' (Loader.UnhandledException)

I see the stack trace starts at Loader.UnhandledException, which is the
event handler I added. However, all I do there is display an error dialog
and log the ExceptionObject. Does this mean the unhandled error did not
originate from within my app? If that is not the case, why can't I see a
more detailed stack trace, indicating from where the error originated?
Could you post the code of your UnhandledException method?

Sep 15 '06 #3
"Flack" <Fl***@discussions.microsoft.comskrev i en meddelelse
news:17**********************************@microsof t.com...
UnhandledException, Exception='System.IO.IOException: An unexpected
network
error occurred.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32
count)
at System.IO.FileStream.FlushWrite()
at System.IO.FileStream.Flush()
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.FileStream.Finalize()' (Loader.UnhandledException)

I see the stack trace starts at Loader.UnhandledException, which is the
event handler I added. However, all I do there is display an error dialog
and log the ExceptionObject. Does this mean the unhandled error did not
originate from within my app? If that is not the case, why can't I see a
more detailed stack trace, indicating from where the error originated?
Don't know if it's relevant to your case, but do you "re throw" the
exception, and are you aware of the difference between "throw" and "throw
ex" ?
Sep 18 '06 #4
Flack wrote:
Hello,

I added this event to handle unhandled exceptions:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(UnhandledException) ;

Recently one occured and added the following to my log file:

UnhandledException, Exception='System.IO.IOException: An unexpected network
error occurred.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite()
at System.IO.FileStream.Flush()
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.FileStream.Finalize()' (Loader.UnhandledException)

I see the stack trace starts at Loader.UnhandledException, which is the
event handler I added. However, all I do there is display an error dialog
and log the ExceptionObject. Does this mean the unhandled error did not
originate from within my app? If that is not the case, why can't I see a
more detailed stack trace, indicating from where the error originated?
You need to check the InnerException property of that exception. And
then the InnerException property of the InnerException... etc.

Something like this:

StringBuilder sb = new StringBuilder();
while (ex != null)
{
sb.Append(ex.Message + ": " + ex.StackTrace);
ex = ex.InnerException;
}
MessageBox.Show(sb.ToString());

Sep 18 '06 #5

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

Similar topics

3
by: JWA | last post by:
Hi All, How can you capture unhandled exceptions thrown by an MDI child form separate from the entire app? I have an application-wide exception handler to catch crashes by doing the following...
12
by: Mark | last post by:
Apologies for the lengthy posting.... In a previous posting:...
9
by: Beeeeeeeeeeeeves | last post by:
Hi I have a service which starts extra threads which take a long time, this is so it can respond to events while long processes are running. I was just wondering, a) if an exception is thrown...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
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...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
16
by: Chuck Cobb | last post by:
I'm implementing a centralized exception handling routine using the Enterprise Library Exception Management Application Block. I trap all unhandled exceptions to one place using the following...
2
by: Bob | last post by:
I MUST be able to trap unhandled exceptions, bring the thread to a routine that then closes the thread on which the execption occurred without closing or affecting the other threads. Think of an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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.