“不允许更改为 64 位应用程序”在 Visual Studio 2008 中调试时
我正在使用 Visual Studio 2008,C#。我尝试使用编辑并继续(在调试时编辑代码),并得到此异常:
“不允许更改 64 位应用程序”
这是为什么?有解决方法吗?
I'm using Visual Studio 2008, C#. I try to use edit-and-continue (edit the code while debugging), and get this exception:
"Changes to 64-bit applications are not allowed"
Why is that? Is there a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
64 位应用程序在 CLR 级别不支持“编辑并继续”,因此 Visual Studio 也无法实现它。
解决此问题的最简单方法是将您的应用程序定位到 x86 芯片。这将导致它作为 32 位进程在 Wow64 模式下运行,因此能够进行 ENC。您可以通过执行以下操作来完成此操作:
Edit and Continue is not supported on 64 bit applications at the CLR level so there is no way for Visual Studio to implement it either.
The easiest way to work around this problem is to target your application to x86 chips. This will cause it to run in Wow64 mode as a 32 bit process and hence be able to ENC. You can do this by doing the following
就我个人而言,我真正想要的是停止并编辑而不是编辑并继续。
所以我只是关闭工具/选项/调试/编辑并继续。
这样做可以防止那个讨厌的对话框纠缠我关于我一开始不想要的缺失功能:-)
Personally, what I actually want is stop-and-edit not edit-and-continue.
So I simply turn off Tools / Options / Debugging / Edit and Continue.
Doing so inhibits that pesky dialog box from pestering me about a missing feature I didn't want in the first place :-)
Visual Studio 2013 将支持 64 位代码的“编辑并继续”功能。
更多信息请参见此处。
The "Edit and Continue" feature for 64-bit code will be supported under Visual Studio 2013.
More information here.
正如 jcopenha 所说,x64 上还没有编辑并继续功能。当前版本的 64 位 CLR 不支持它。不过,有一个解决方法。
您可以在 Bug Babble 帖子 上找到它。
希望有帮助。
Like jcopenha said there's no edit-and-continue on x64 yet. Current version of the 64bit CLR does not support it. However, there's a work around.
You can find it on Bug Babble post.
Hope it helps.
编辑并继续功能尚未在 x64 中实现。我还没有听到他们计划何时进行的任何更新。
另请参阅为什么“编辑并继续”无法在x64 CLR?
The edit-and-continue feature simply hasn't been implemented in x64 yet. I haven't heard any updates on when they plan to do it yet.
See also Why doesn't Edit and Continue work on the x64 CLR?
我在 MS Visual C# Express 2010 中遇到了同样的错误消息。不过这很有趣,因为该应用程序肯定被配置为 x86 项目!
最后,我的 .csproj 文件中缺少以下行:
我不知道为什么缺少它......我猜 MS Visual C# Express 2010 不是没有错误的;)
I had the same error message in MS Visual C# Express 2010. It was funny though, because the application was definitely configured as an x86 Project!
In the end, it was the following line missing in my .csproj file:
I don't know why it was missing ... I guess MS Visual C# Express 2010 is not bugfree ;)
当目标CPU设置为“任何CPU”时,它将在32位Windows上作为32位应用程序运行,在64位Windows上作为64位应用程序运行。但是,Visual Studio 不允许 64 位应用程序使用“编辑并继续”功能。
为了在 64 位机器上“流畅”地调试,我们可以:
a) 将“目标 CPU”设置为“任何 CPU”,但选中“首选 32 位”框。
b) 或者,将“目标 CPU”设置为“x86”
非常重要:这两个选项都需要取消选中“启用优化”框。
when Target CPU is set to 'Any CPU', it will run as a 32bit application on a 32bit windows, and 64bit application on a 64bit windows. However visual studio does not allow 'edit-and-continue' feature for 64bit application.
In order to debug 'fluently' on 64bit machine, we can either:
a) set 'Target CPU' to 'Any CPU' but check the 'Prefer 32bit' box.
b) or, set 'Target CPU' to 'x86'
VERY important: both option requires the 'Enable optimizations' box to be unChecked.
遗憾的是,64 位不支持“编辑并继续”。事实上,如果您尝试使用 Edit &继续调试 64 位应用程序时,您会收到以下错误消息:“不允许更改 64 位应用程序”
许多用户可能不知道,默认情况下,当您在 Visual Studio 2008 中创建 C# 或 VB 项目时,该项目的“平台”被设置为“任何 CPU”。这意味着,如果您在 32 位操作系统上运行应用程序,您的应用程序将作为 32 位进程运行,同样,如果您在 64 位操作系统上运行应用程序,则应用程序将是 64 位的。 “任何 CPU”的后果是,当您尝试在 64 位操作系统上调试应用程序时,您将无法使用“编辑并继续”功能。
不过,有一个解决方法。在开发过程中,您可以将项目的平台设置为 32 位,这意味着您的应用程序即使在 64 位操作系统上也将作为 32 位进程运行。这称为 WOW64 或“Windows On Windows”,基本上意味着您可以在 64 位操作系统上运行 32 位应用程序。
那么,如何将项目的平台设置为 32 位呢?那么,您需要使用 Visual Studio 配置管理器创建一个 32 位平台。这是一个简短的演练。
首先,从Build –> 打开“Configuration Manager”对话框配置管理器。配置管理器对话框如下所示。
Unfortunately, Edit and Continue isn't supported on 64-bit. In fact, if you try to use Edit & Continue when debugging a 64-bit application, you get the following error message: "Changes to 64-bit applications are not allowed"
Many users may not be aware that by default, when you create a C# or VB project in Visual Studio 2008, the "Platform" for the project is set to "Any CPU". This means that if you run your application on a 32-bit operating system, your application will run as a 32-bit process and similarly, if you run your application on a 64-bit operating system, the application will be 64-bit. The consequence of "Any CPU" is that when you try to debug your application on a 64-bit operating system, you won't be able to use the Edit and Continue feature.
However, there is a workaround. During development, you can set the Platform for your project to 32-bit which means that your application will run as a 32-bit process even on a 64-bit operating system. This is known as WOW64 or "Windows On Windows" which basically means that you can run a 32-bit application on a 64-bit operating system.
So, how do you set the Platform for your project to 32-bit? Well, you need to create a 32-bit platform using the Visual Studio Configuration Manager. Here is a short walkthrough.
First, open the "Configuration Manager" dialog from Build –> Configuration Manager. The Configuration Manager dialog is shown below.