An Easy Way to Cause Stack Overflow
Posted in Development
If you’ve ever been greeted with the following red-on-white error message, I’ve got a tip for you.
Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.
In my experience, in nine out of ten cases this happens due to a sloppy or altogether unintentional recursion. See if you spot the problem:
public class Foo { private string bar; // ... public string Bar { get { return Bar; } } }
The Bar property references itself instead of the
bar member. These cyclic calls exhaust the call stack, and you get the cryptic message above.
ReSharper has very aggressive IntelliSense and readily offers auto complete suggestions. I don’t even remember how many times I’ve walked into this trap. Granted, ReSharper displays a little recursion glyph, but who pays attention to the scenery at high speed? :)
Ironically, naming class members in Hungarian notaion or with underscores mitigates the problem.
6 comments
Milan Negovan
on May 9, 2007
Rik, very true! Good point. I'm still wrestling with unit testing in ASP.NET.
Josh Stodola
on May 15, 2007
Naming conventions can really save some grief!! This is another reason I always use 3 letter prefixes for all variables. Like:
Dim strName as String
Dim intAge as Integer
Dim blnAdmin as Boolean
Best Regards
Michelle
on June 6, 2007
@Josh
well, nice trick, it will save me some trouble, thanks for sharing it :)
Pendrive
on March 30, 2008
It’s very good article. Great site with very good look and perfect information.

Damir
on May 5, 2007
Yes, I've done it by myself a time or two... That's the one of two reasons why I've adopted '_' prefix as a naming standard for private fields.
Second reason is to have naming standard compatible with VB.NET (I had to use it in some projects in my previous job...).