Tuesday, December 28, 2010

0002 StackOverflow


I hate these errors in third party APIs. The only way to handle them in .NET is the load your assembly in a new AppDomain.
Here is the code I used to get the screenshot:

namespace B { class A { static void Main() { Main(); } } }

This just happens to be the shortest compilable code in C# that you can write that contains at least one function call in Main. And by definition also the shortest code that can raise a StackOverflow Exception. Also it requires no usings

MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSO

No comments:

Post a Comment