简体   繁体   English

尝试在VS2013中以调试模式编辑代码时出错

[英]Error while trying to edit code in debugging mode in VS2013

I'm a C# programmer and recently I've installed Visual Studio 2013. The problem is when i set a break point or get an error and trying to edit the codes while debugging I get this error and I couldn't find the same error searching on Google. 我是一个C#程序员,最近我安装了Visual Studio 2013.问题是当我设置一个断点或得到一个错误并试图在调试时编辑代码我得到这个错误,我找不到相同的错误在Google上搜索。

Changes are not allowed for this module as it was not built for changes while debugging or the target .NET runtime version does not support it 此模块不允许更改,因为它不是在调试时生成的更改,或者目标.NET运行时版本不支持它

I also tried to check the options on Tools -> Options -> Debugging -> Edit and Continue , But didn't help. 我还尝试检查Tools -> Options -> Debugging -> Edit and Continue ,但没有帮助。

Any idea what the problem is? 知道问题是什么吗?

To edit a C# program while you're running it in Visual Studio 2013: 要在Visual Studio 2013中运行C#程序时编辑它,请执行以下操作:

  1. Go to Project, Properties, Build. 转到项目,属性,构建。
  2. Set Platform target: x86 设置平台目标:x86
  3. Disable "Optimize code" 禁用“优化代码”
  4. Set Advanced, Debug Info: Full 设置高级,调试信息:完整

我遇到了同样的问题,发现顶部栏上的“解决方案配置”已更改为Release from Debug,因为我将最后一个版本构建到Release文件夹中。更改回调试模式将解决问题。

The code your probably modifying is included in the exception. 您可能修改的代码包含在异常中。 Since, your code is not posted here, I can't say. 既然,你的代码不在这里发布,我不能说。 So please refer to this link and check whether it is really not allowed. 所以请参考此链接并检查是否真的不允许。

我们在Visual Studio 2013中遇到了同样的问题,在我们的例子中,这是因为我们在“项目设置”的“调试”选项卡上禁用了Visual Studio托管过程。

I just had the same problem and found a solution that worked for me right here after trying 100 other things: 我遇到了同样的问题,在尝试了100个其他的东西之后找到了一个适合我的解决方案:

https://stackoverflow.com/a/12543388/5367013 https://stackoverflow.com/a/12543388/5367013

1.) execute VsPerfCLREnv /globaloff 2.) reboot your computer 1.)执行VsPerfCLREnv / globaloff 2.)重新启动计算机

In a Web Forms application, I initially received the "Changes are not allowed for this module as it was not built for changes while debugging or the target .NET runtime version does not support it" error message. 在Web窗体应用程序中,我最初收到“此模块不允许更改,因为它不是为调试时的更改而构建的,或者目标.NET运行时版本不支持它”错误消息。 Based on suggestions above I completed the following: 根据上述建议,我完成了以下内容:

  1. Right click the project name, just under the Solution name in Solution Explorer and select Properties, the "Build" tab 右键单击项目名称,在Solution Explorer中的Solution name下,选择Properties,“Build”选项卡
  2. Set Platform target: x86 (Note, for me this was already set) 设置平台目标:x86(注意,对我来说这已经设置了)
  3. Disable "Optimize code" 禁用“优化代码”
  4. Click the “Advanced” button (near bottom) and set, Debug Info: Full 单击“高级”按钮(靠近底部)并设置“调试信息:完整”

I tried to modify code, but then I received the "Edit and Continue" window stating "Changes are not allowed while code is running." 我试图修改代码,但后来我收到了“编辑并继续”窗口,指出“代码运行时不允许进行更改”。

Here was the important part: I can only make changes while stopped at a breakpoint. 这是重要的部分:我只能在断点停止时进行更改。 If the page is loaded, I get that same "Changes are not allowed..." message. 如果页面已加载,我会得到相同的“不允许更改...”消息。 So set a breakpoint to a line above where you need to make the change, complete the update and you should be set. 因此,设置断点到上面需要进行更改的行,完成更新,然后设置。

Or (as I subsequently discovered) another way to modify code without using a breakpoint is to click in Visual Studio "Debug/Break All" (Ctrl+Alt+Break), make your change and then press F5 or click the "Continue" button. 或者(我后来发现)另一种不使用断点修改代码的方法是在Visual Studio中单击“Debug / Break All”(Ctrl + Alt + Break),进行更改,然后按F5或单击“继续”按钮。 (Using this method you will might need a page refresh to see the mods.) (使用此方法,您可能需要刷新页面才能看到mod。)

调试时编辑

It worked for me by unchecking "Enable optimizations" option. 通过取消选中“启用优化”选项,它对我有用。

Please refer below image for more info. 有关详细信息,请参阅下图。

You can try 你可以试试

  1. Right click 'Solution' in the Solution Explorer. 右键单击Solution Explorer中的“Solution”。
  2. Select Properties. 选择属性。
  3. Choose Configuration Properties from the left menu. 从左侧菜单中选择“配置属性”。
  4. Select 'Debug' from the dropdown list in the upper-left corner labeled 'Configuration:'. 从标有“Configuration:”的左上角的下拉列表中选择“Debug”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM