See Also: StackOverflowException Members
StackOverflowException is thrown for execution stack overflow errors, typically in the case of a very deep or unbounded recursion.
The localloc CIL instruction throws StackOverflowException.
The following example demonstrates an error that causes a StackOverflowException exception.
C# Example
using System;
public class StackOverflowExample {
public static void recursion() { recursion(); }
public static void Main() {
try {
recursion();
}
catch(StackOverflowException e) {
Console.WriteLine("Error caught: {0}", e);
}
}
}
The output is
Error caught: System.StackOverflowException: Exception of type System.StackOverflowException was thrown.