I have not seen a stackoverflow exception for a long time. Today I happened to bump into one in random test code. I will explain how it happened. What the code is used for and why it was written this way are not interesting to me and are not in the scope of this post.
public class ChildClass : BaseClass { protected override void Dispose(bool disposing) { if (disposing) { base.Dispose(); //DO something } } } public class BaseClass { public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { //DO something } } }
As you can see the stackoverflow exception will happen as the below
1. Child.Dispose(bool)
2. Base.Dispose()
3. Child.Dispose(bool)
4. Base.Dispose()
…
Pingback: StackOverflow Exception, Long time no see - Paul Lou's blog - Site Home - MSDN Blogs