Krumelur
Krumelur

Reputation: 33068

Why is ASP.NET throwing so many exceptions?

By coincidence I watched the debug output of Visual Studio a bit. I can see hundreds and hundreds of various exceptions being thrown. I checked another ASP.NET based solution and it is showing same behavior. Why are all those exceptions thrown? I cannot believe it is good for the overall performance, is it? Look at the excerpt below. It is the output of appr. 30 seconds surfing. Most are HttpExceptions but there are also FormatExceptions and ArgumentOutOfRangeExceptions. None of these is really affecting the usage. Nothing crashes. Does anybody have an explanation, as it seems to be "normal"?

A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
'w3wp.exe' (Managed): Loaded 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a402e511\e6aaa0de\App_Web_vdj_eurz.dll', Symbols loaded.
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll
A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

Upvotes: 31

Views: 51331

Answers (4)

Tedd Hansen
Tedd Hansen

Reputation: 12316

I'm not sure exactly what is causing it, but I know how you can find out (even better, right?:)).

In Visual Studio:

  • Click on "Debug" menu
  • Click on "Exceptions..."
  • Check "Thrown" on "Common Language Runtime Exceptions"

This will make Visual Studio halt the debugger on any exception so you can check what is actually happening. (does not affect production code, only halts in VS)

As a sidenote you may want to implement something like automatic exception emailing or similar to get more info from a production site.

Note that you may not be able to catch all exceptions in VS out of the box (first time exceptions may sometimes be a bit elusive). If you want to be more hardcore you can have Visual Studio debugger debug the .Net Framework too. Your goal should be to see the full exception + stack trace, that will in most cases tell you all about what is going wrong.

A good practice is to get rid of the exceptions (find cause and fix), don't hide or ignore them.

EDIT

It's also worth nothing that "first chance exceptions" are exceptions that may very well be captured by a try-catch. Some internal functions in .Net will throw an exception when a certain condition is met, this is part of how Visual Studio/debugging works and doesn't mean something has crashed. Visual Studio will log these for you just in case you need them, but it doesn't mean you have to act upon them.

Upvotes: 39

MandoMando
MandoMando

Reputation: 5515

Additional (perhaps useful) info:

Amongst many reasons, this could be caused by the site/webapp not having a favicon.ico file.

If the actual exception is: System.Web.StaticFileHandler.GetFileInfo it's obviously a file not found. And if you're not seeing the actual 404 error on the browser, it's likely because the browser quietly goes about its business when it doesn't find favicon.ico.

Upvotes: 3

user1228
user1228

Reputation:

Who knows???

But you can find out. Hit ctrl-alt-E, and in the Exceptions dialog instruct the debugger to break when the exception is thrown:

exceptions dialog

When it breaks, check the InnerException property to see what caused the HttpException.

Upvotes: 25

NakedBrunch
NakedBrunch

Reputation: 49423

Take a look at this URL for a detailed look at these messages: http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx.

If you like, you can disable this output by going to:

Tools --> Options --> Debugging --> General --> uncheck Redirect all Output Window text to the Immediate Window

Upvotes: 6

Related Questions