在使用Reference Source调试.Net 源代码时如何取消optimizations(代码优化)

当你在使用Reference Source functionality in VS 2008 调试.Net 的源代码的时候,你会发现很多变量没法再调试时查看。

image

这是因为源代码服务器上提供的代码默认是为最终销售优化过的(optimized )。这些值虽然你没法查看,但不会阻断单步执行,大部分情况下你可能不需要查看。

但如果你真的需要查看,这里还是有一个办法的。

你需要靠诉CLR不要加载pre-JIT(也加NGEN)镜像。下面是具体步骤:

首先,创建一个CMD文件。文件里包含这么几步,设置一个环境变量,随后启动Visual Studio。 我把这个文件命名为"NoOptDevEnv.cmd",具体内容如下:

set COMPLUS_ZapDisable=1     
cd /d "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\ide\"      
start devenv.exe      
exit

我把这个CMD文件文件放在我的桌面,当我需要禁止优化(optimizations)的时候就用这个文件启动VS。

一旦Visual Studio启动,还需要做以下步骤:

  1. 右键单击你的项目文件,选择“属性”
  2. 选择“调试(Debug)”,取消勾选"允许Visual Studio托管进程(Enable the Visual Studio Hosting Process)"
  3. 在调试模式启动你的程序。

现在,你可以看到所有的本地和成员变量的值了:

image

英文原文:http://blogs.msdn.com/b/sburke/archive/2008/01/29/how-to-disable-optimizations-when-debugging-reference-source.aspx

转自中文博客:http://www.cnblogs.com/DotNetNuke/archive/2013/01/14/2859448.html#2600526

 

 

源码dll: ComSvcConfig mscorlib PresentationBuildTasks PresentationCore PresentationFramework PresentationFramework.Aero PresentationFramework.Classic PresentationFramework.Luna PresentationFramework.Royale SMDiagnostics SMSvcHost svcutil System System.Activities System.Activities.Core.Presentation System.Activities.DurableInstancing System.Activities.Presentation System.AddIn System.AddIn.Contract System.ComponentModel.DataAnnotations System.Configuration System.Core System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.Services System.Data.Services.Client System.Data.Services.Design System.Data.SqlXml System.Drawing System.IdentityModel System.IdentityModel.Selectors System.IO.Log System.Management System.Messaging System.Net System.Numerics System.Runtime.Caching System.Runtime.DurableInstancing System.Runtime.Remoting System.Runtime.Serialization System.Security System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Transactions System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Windows.Forms System.Workflow.Activities System.Workflow.ComponentModel System.Workflow.Runtime System.WorkflowServices System.Xaml.Hosting System.Xml System.Xml.Linq UIAutomationClient UIAutomationClientsideProviders WindowsBase WsatConfig WsatUI XamlBuildTask
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值