.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 som开发者_Go百科e tools etc.
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.
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).
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.
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()
.
精彩评论