The exception that is thrown when the execution stack overflows because it contains too many nested method calls. This class cannot be inherited.
Assembly: mscorlib (in mscorlib.dll)
is thrown for execution stack overflow errors, typically in case of a very deep or unbounded recursion. The Localloc Microsoft intermediate language (MSIL) instruction throws .
uses the HRESULT COR_E_STACKOVERFLOW, which has the value 0x800703E9. For a list of initial property values for a object, see the StackOverflowException constructors.
The value of the inherited Data property is always null.
In prior versions of the .NET Framework, your application could catch a object (for example, to recover from unbounded recursion). However, that practice is currently discouraged because significant additional code is required to reliably catch a stack overflow exception and continue program execution.
Starting with the .NET Framework version 2.0, a object cannot be caught by a try-catch block and the corresponding process is terminated by default. Consequently, users are advised to write their code to detect and prevent a stack overflow. For example, if your application depends on recursion, use a counter or a state condition to terminate the recursive loop. Note that an application that hosts the common language runtime (CLR) can specify that the CLR unload the application domain where the stack overflow exception occurs and let the corresponding process continue. For more information, see ICLRPolicyManager Interface and Hosting the Common Language Runtime.
Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition Platform Note: A thrown cannot be caught by a try-catch block. Consequently, the exception causes the process to terminate immediately.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.