如何编辑我的代码,而使用Visual Studio调试? [英] How can I edit my code while debugging using Visual Studio?

查看:248
本文介绍了如何编辑我的代码,而使用Visual Studio调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改我的代码,同时调试它,所以当它打破我去看看原代码?

How can I change my code while debugging it so when it breaks I'll see the original code?

我有几个小时或几天运行的程序,我想调试。同时,而不是等待我想保持它的代码工作。
但是,如果我更改代码,我不能打破我运行的会话,并看到它的原代码。

I have a program that runs for hours or days, and I want to debug it. Meanwhile instead of waiting I want to keep working on it's code. But if I change the code I can't break my running session and see it's original code.

编辑:
我禁用了编辑并继续功能,才能做到这一点,因为当它的启用,调试器,我的解决方案被锁定并且不能改变。

I disabled the "Edit and Continue" feature in order to do so, because when it's enabled and the debugger is on, my solution gets "locked" and can't be changed.

推荐答案

您需要您的解决方案的两个副本:

You need two copies of your solution:


  • 一个继续工作就可以了

  • 其他与原来的代码,因为它是当你开始调试应用程序

现在的Visual Studio中打开两个实例:

Now open two instances of Visual Studio:


  • 其他副本,以保持它的工作

  • 一个具有原始的源代码,并附着在调试过程中

您可以安全地拥有了在调试实例启用编辑并继续选项,并有使用此功能 - 即你可以尝试在原始源代码的变化,看它是否正常工作,然后在您的解决方案的工作副本应用同样的变化。

You can safely have the "edit and continue" option enabled in your debugging instance, and use this functionality there - i.e. you can try a change in the original source code to see if it works as expected, and then apply the same change in the working copy of your solution.

这是做到这一点的唯一方法。如果你没有拆开的原始源代码,调试器没有办法向你展示原始源代码

This is the only way to do it. If you don't have the original source code apart, the debugger has no way to show you the original source code.

请注意:您可以打开VS的新实例与原来的源代码,和附加到正在运行的过程,然后从过程和关闭VS分离不与运行的应用程序干扰。查看选项附加到进程...和分离所有的调试菜单。

Note: you can open a new instance of VS with the original source code, and attach to the running process, and then detach from the process and close VS without interfering with the running application. See the options "Attach to process..." and "Detach all" of the "Debug" menu.

这篇关于如何编辑我的代码,而使用Visual Studio调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆