



If your app hosts the common language runtime (CLR), it can specify that the CLR should unload the application domain where the stack overflow exception occurs and let the corresponding process continue. You still cannot handle the exception from user code. See the Examples section for an illustration of this technique.Īpplying the HandleProcessCorruptedStateExceptionsAttribute attribute to a method that throws a StackOverflowException has no effect. For example, if your app depends on recursion, use a counter or a state condition to terminate the recursive loop.
#Linked list stack overflow code
Consequently, you should write your code to detect and prevent a stack overflow. NET Framework 2.0, you can't catch a StackOverflowException object with a try/ catch block, and the corresponding process is terminated by default. For a list of initial property values for a StackOverflowException object, see the StackOverflowException constructors. The Localloc intermediate language (IL) instruction throws StackOverflowException. StackOverflowException uses the HRESULT COR_E_STACKOVERFLOW, which has the value 0x800703E9. So make sure your code doesn't have an infinite loop or infinite recursion. StackOverflowException is thrown for execution stack overflow errors, typically in case of a very deep or unbounded recursion. ' The example displays the following output: Private const int MAX_RECURSIVE_CALLS = 1000 Ĭonsole.WriteLine("\nThe call counter: to the Execute method", ctr) The following example uses a counter to ensure that the number of recursive calls to the Execute method do not exceed a maximum defined by the MAX_RECURSIVE_CALLS constant. SerializableAttribute ComVisibleAttribute Examples
