[Original] bug report, submitted to Microsoft. When the Platform calls debugging, it cannot perform a single-step error on the unmanaged function.

Source: Internet
Author: User

Detailed description:

First, declare the unmanaged functions:

[Dllimport ("nativelib. dll", charset = charset. Unicode, callingconvention = callingconvention. cdecl)]

Private extern static void teststringargumentsfixlength (string instring, stringbuilder outstring, int buffersize );

 

Then select"Enable unmanaged code debugging"


 

 

Write as follows:CodeTest:

Private Static void teststringargumentsfixlength ()

{

String instring = "this is a input string .";

 

Int buffersize = instring. length;

Stringbuilder sb = new stringbuilder (buffersize );

 

Teststringargumentsfixlength (instring, Sb, buffersize + 1 );

 

Console. writeline ("Original: {0}", instring );

Console. writeline ("Copied: {0}", SB. tostring ());

}

 

Click the breakpoint in the red line and pressF11You can step into an unmanaged function.

 

However, if you modify it:

Private Static void teststringargumentsfixlength ()

{

String instring = "this is a input string .";

 

Int buffersize = instring. length;

Stringbuilder sb = new stringbuilder (buffersize );

 

//If the last parameter of the above function call isStringbuilderSpecifies the attributes of an object.

//Although the running result is correct, the debugger

//The Code cannot be executed in a single step. This may be. NET FrameworkSmallBug.

Teststringargumentsfixlength (instring, Sb,SB. Capacity + 1);

 

Console. writeline ("Original: {0}", instring );

Console. writeline ("Copied: {0}", SB. tostring ());

}

 

Click the breakpoint in the red line and pressF11In any case, you cannot step into an unmanaged function.

 

 

Test environment:

Windows Server 2008

Windows Vista Enterprise

Windows XP SP2

 

Development tools:

Microsoft Visual maxcompute 2005

Version 8.0.50727.42RTM.050727-4200)

Microsoft. NET Framework

Version 2.0.50727 SP1

 

 

YesSource codeIf you try it yourself, please download:

Source code

 

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.