whoi
whoi

Reputation: 3421

.Net Exception detail

How can one get detailed Exception thrown by the .net framework. The below log fragment shows something is wrong but what?

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Unfortunately I can not catch this exception so I can not debug. Is there a way to get a detailed information about such exceptions? May be some tools etc.

Upvotes: 1

Views: 965

Answers (4)

Kent Boogaart
Kent Boogaart

Reputation: 178640

The fact that you have a log implies something is logging the exception. What are you using to log the exception? It sounds as though it may be logging just Exception.Message rather than Exception.ToString().

Upvotes: 0

Chris
Chris

Reputation: 27599

I think its worth also looking at what the difference is between first and second chance exceptions. http://support.microsoft.com/kb/105675 explains it in detail but in brief a first chance exception is thrown the moment an exception is thrown. That is before any attempt has been made to handle it through try/catch statements. This is likely to mean that the framework caught the exception and did something else appropriate, etc.

This generally means that first chance exceptions are not things to worry about, only worry about other people's code throwing exceptions if they make it as far as your code, otherwise trust in their error handling.

Upvotes: 0

Marcel
Marcel

Reputation: 15722

Are you using Visual Studio (2008)?
Then you could catch any exception, even if it is not handled by your code, using the Exceptions options dialog in the Debug/Exceptions menu.

Upvotes: 2

Camilo Martin
Camilo Martin

Reputation: 37898

First, FileNotFoundExceptions is blunt clear.

Second, use try...catch blocks when ANY code depends on reading a file on disk.

For more information, read about catching exceptions and what to do (normally tell the user the file was not found).

Upvotes: 0

Related Questions