有没有办法*完全禁用编辑和继续? [英] Is there a way to *completely* disable Edit and Continue?

查看:185
本文介绍了有没有办法*完全禁用编辑和继续?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法在Visual Studio 2008中进行调试时完全锁定代码。代码文件在作为64位应用程序运行时自动锁定,我非常喜欢;不过,我做大部分的编写Excel的加载项,这是32位。结果是即使我的目标是AnyCPU,VS主机知道它正在32位进程中运行,因此,当代码运行在Visual视图中时,源代码不被锁定工作室。

我可以通过转到工具>选项>调试>编辑并继续,然后取消选中启用编辑并继续复选框,关闭编辑和继续。然而,这并不完全锁定代码。这样做不会阻止代码中的任何编辑在当前运行中执行,但它不会阻止鼠标点击或击键实际更改代码。



再次,当使用64位应用程序时,这不会发生 - 代码被完全锁定。我非常喜欢代码被完全锁定至少有两个原因:


  1. 我可以不小心点击一个键或像调试一样,我绝对不想做。这很罕见,但这是一个问题。


  2. 我的许多自动测试通过SendKeys驱动用户界面。然而,当使用调试器进行这样的测试时,我有时可能会忘记某些方面涉及到SendKeys,这意味着按键会被发送到Visual Studio IDE而不是Excel。


在上述问题#2中,单元测试失败,这很好 - 我的坏 - 但是所有发送到代码模块的按键都是完全不可接受的。



有没有人有任何想法?在针对32位CPU编译时,可以在Visual Studio中运行托管时,是否可以完全锁定代码?



有关这个问题的一些相关帖子,但没有一个直接解决这个问题:





提前感谢任何帮助或想法...



Mike

解决方案

这是我能想出来的最好的。它有效,但是您可能不想采取一些步骤。



本质上,该技术是在运行应用程序时将项目的文件设置为只读,然后在应用程序结束后将其设置为可写。



但是,在VS2k8中,默认情况下,将文件设置为只读仍可允许您编辑文件。您需要先在工具>选项>环境>文档中关闭允许只读文件的编辑...设置。



其次,您需要将以下键作为DWORD添加到注册表中,并将其值设置为1:

  HKCU\Sofware\Microsoft\Visual Studio\9.0 \Source Control\UncontrolledInMemoryEditDialogSuppressed 

这个仍然将无法正常工作。然后,您需要做的是将该项目的源代码控制设置为Visual Source Safe。 (< - 这是我假设你不会喜欢的步骤。)



然后重新启动VS2k8。



在这一点上,如果您将其中一个文件设置为只读,您将看到Visual Studio不会让您完全编辑此文件。当您尝试时,它会播放您的计算机的异常音乐。



现在,要在运行应用程序时将文件设置为只读,请设置后期制作流程。这很容易。



更难的是,一旦你的应用程序完成运行,就将它们设置为可写。最简单的解决方案可能是批处理文件快捷方式。


I was wondering if there was a way to completely lock my code while debugging it within Visual Studio 2008. The code documents lock automatically when running as 64 bit applications, which I greatly prefer; however, I do most of my coding making add-ins for Excel, which is 32 bit. The result is that even though I target 'AnyCPU', the VS host knows that it is running within a 32 bit process and, therefore, the source code is not locked while the code is running hosted in Visual Studio.

I can turn off Edit and Continue by going to Tools > Options > Debugging > Edit and Continue, and then unchecking the 'Enabled Edit and Continue' check box. This does not completely lock the code, however. This does prevent any edits in the code from being executed in the current run, but it does not prevent mouse clicks or keystrokes from actually changing the code.

Again, when working with 64 bit applications this does not occur -- the code is completely locked. I greatly prefer the code to be completely locked for at least a couple of reasons:

  1. I can accidentally hit a key or the like while debugging, which I definitely do not want to do. It's rare, but it is an issue.

  2. Many of my automated tests drive the user interface via SendKeys. When stepping through such a test using the debugger, however, I can sometimes forget that some of the aspects involve SendKeys, which means that keystrokes wind up getting sent to the Visual Studio IDE instead of Excel.

In issue #2, above, the unit test fails, which is fine -- my bad -- but having all the keystrokes sent to the code module and destroying my code is completely unacceptable.

Does anyone have any ideas here? Can one completely lock the code when running hosted in Visual Studio while compiled against a 32 bit CPU?

Some related posts on this issue, but none of which directly address this:

Thanks in advance for any help or ideas...

Mike

解决方案

Here is the best I could come up with. It works, but there are some steps you may not want to take.

Essentially, the technique is to set the files of your project to Read-Only when you run the application, and then set them back to writable once your application ends.

However, in VS2k8, by default, setting a file to Read-Only still allows you to edit the file. You need to first turn off the setting "Allow editing of read-only files..." in Tools > Options > Environment > Documents.

Second, you need to add the following key to the registry as a DWORD and set its value to 1:

HKCU\Sofware\Microsoft\Visual Studio\9.0\Source Control\UncontrolledInMemoryEditDialogSuppressed  

This still won't work completely. What you then have to do is set your Source Control for that project to Visual Source Safe. (<-- this is the step I'm assuming you won't like.)

Then restart VS2k8.

At this point if you set one of your files to read-only, you will see that Visual Studio will not let you edit this file at all. When you try, it plays your computer's exception music.

Now, to make your files read-only when you run the app, set a post-build process to do this. That's easy.

Harder, is to set them back to writable once your app finishes running. The simplest solution is probably a batch file shortcut.

这篇关于有没有办法*完全禁用编辑和继续?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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