在调试同时存在托管代码和非托管代码的程序的时候,需要特别注意选用适当的调试器的类型。因为看到类似的问题问得比较多,因此这里把做法写出来。
在托管项目中在调试之前,需要打开对非托管代码调试的功能,这个选项在项目的属性的Debug选项中存在:
<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter" /> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0" /> <v:f eqn="sum @0 1 0" /> <v:f eqn="sum 0 0 @1" /> <v:f eqn="prod @2 1 2" /> <v:f eqn="prod @3 21600 pixelWidth" /> <v:f eqn="prod @3 21600 pixelHeight" /> <v:f eqn="sum @0 0 1" /> <v:f eqn="prod @6 1 2" /> <v:f eqn="prod @7 21600 pixelWidth" /> <v:f eqn="sum @8 21600 0" /> <v:f eqn="prod @7 21600 pixelHeight" /> <v:f eqn="sum @10 21600 0" /> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /> <o:lock v:ext="edit" aspectratio="t" /> </v:shapetype><v:shape id="Picture_x0020_10" o:spid="_x0000_i1027" type="#_x0000_t75" style='width:406.5pt;height:261pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\ATField\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" o:title="" /> </v:shape><![endif]--><!--[if !vml]-->
<!--[endif]-->
打上钩即可。
如果是在Attach到一个进程的时候,需要在Attach to Process这个对话框中选择进程的类型:
<!--[if gte vml 1]><v:shape id="Picture_x0020_11" o:spid="_x0000_i1026" type="#_x0000_t75" style='width:617.25pt;height:165pt; visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\ATField\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png" o:title="" /> </v:shape><![endif]--><!--[if !vml]-->
<!--[endif]-->
缺省是自动选择,不过这个并不是总是正确,最好自己选择正确的类型。点击Select弹出Select Code Type对话框:
<!--[if gte vml 1]><v:shape id="Picture_x0020_7" o:spid="_x0000_i1025" type="#_x0000_t75" style='width:355.5pt;height:186.75pt; visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\ATField\AppData\Local\Temp\msohtmlclip1\01\clip_image005.png" o:title="" /> </v:shape><![endif]--><!--[if !vml]-->
<!--[endif]-->
比如,如果是调试托管和非托管混合的代码,则把Managed和Native都勾上即可 。
作者: 张羿(ATField)
Blog: http://blog.youkuaiyun.com/atfield
http://blogs.msdn.com/yizhang
转载请注明出处
本文介绍如何在Visual Studio中配置调试设置,以便能够同时调试托管代码和非托管代码。具体包括在项目属性中启用非托管代码调试及在附加到进程时选择正确的代码类型。
1329

被折叠的 条评论
为什么被折叠?



