WhenProgramWhat if an exception occurs after running? Very easy, debug! However, if an exception occurs, it will make the debugger unable to work.
If stackoverflowexception is accidentally caused by the tostring method, the Visual Studio debugger cannot work. The test environment is Visual Studio 2012 express for Windows desktop (including update 1 ).
For example, a simple type:
Class Test
{
Public Override StringTostring ()
{
Return This.Tostring ();
}
}
Set the breakpoint and start debugging:
During debugging, the Visual Studio debugger will crash whenever you point your mouse to the test variable. (In fact, here, the Visual Studio debugger will exit silently several seconds after the Debugging starts ).
In some more complexCodeEnvironment (also because of stackoverflowexception in tostring, but the reference relationship of the object is more complex during debugging ):
Visual Studio may prompt "the debugger cannot continue running the process. process was terminated." (the debugger cannot continue running the process and the process is terminated .)
The variable information window may prompt information such as "cannot dereference expression. The pointer is not valid." or "cannot evaluate expression because debugging information has been optimized away. For example:
However, if other common exceptions are induced in tostring, such:
Public Override StringTostring ()
{
Throw New Exception("Test");
}
The debugger displays the full name of the type and does not flash back. unfriendly actions: