Question

So I made a stupid mistake, I called myControl.Controls.Add(myControl);. Easy enough. The interesting thing is that this cause IIS to crash and the exception was thrown in the actual framework. I didn't even break and let me debug, it just fell apart.

It seems like this should have been handled better by the .NET framework than it was. Or should it? Is this expected behavior with a mistake like this, or could it have been handled more elegantly by the debugger?

Was it helpful?

Solution

This is a documented behavior - see the documentation at MSDN

Here's the relevant quote:

Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the corresponding process is terminated by default.

EDIT:
From debugging perspective, as apparently there is no stack trace, if the issue is reproducible then relevant code walk-through (or debugging before actual exception occurs) may pin-point the issue. Yet another way could be to use IIS Debug Diagnostics tool and get the error details and crash dump. Refer this SO answer that seems to suggest similar ways.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top