. Net (C #): Be cautious that stackoverflowexception in tostring will make the debugger unable to work.

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.