views:

69

answers:

5

Hi; 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.

Thanks

A: 

FileNoteFoundException Link

The exception that is thrown when an attempt to access a file that does not exist on disk fails.

Check the file you're trying to access, check that it is there. If it is then you're probably going to need to explain why you can't catch the exception so we can debug it more.

Ian
Okay I know, but this exception is thrown somewhere I can not use try/catch. The file is not accessed by me, by framework...
whoi
A: 

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().

HTH,
Kent

Kent Boogaart
A: 

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).

Camilo Martin
+1  A: 

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.

Marcel
This is good news, I will try it immediately.
whoi
This was pretty good answer, thanks
whoi
A: 

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.

Chris