编辑并继续功能在 Visual Studio 2010 中停止工作
Visual Studio 编辑并继续功能在 Visual Studio 2010 上停止,我不知道是什么导致了该问题。
我正在使用 C# 开发 Windows 应用程序。该应用程序最初是在 Visual Studio 2008 中开发的,后来升级到 Visual Studio 2010。
一切都工作正常,包括编辑和继续,直到我将 .NET Framework 从 3.5 升级到 4.0。
现在,当我使用调试模式时,更改 IDE 中的任何代码行都会产生以下消息:
进行了无法编译的编辑。执行无法继续,直到 编译错误已修复。
实际上,没有编译错误,我必须重新启动 Visual Studio 才能运行更新。
如何才能再次编辑并继续工作?
The Visual Studio Edit and Continue feature stopped on Visual Studio 2010, and I don't know what has caused the problem.
I am working on a Windows application program using C#. This application was initially developed in Visual Studio 2008, and later upgraded to Visual Studio 2010.
Everything was working fine, including Edit and Continue, until I upgraded the .NET Framework from 3.5 to 4.0.
Now when I use debug mode, changing any line of the code in the IDE results in the following message:
Edits were made which cannot compiled. Execution cannot continue until
the compile errors are fixed.
Actually, there are no compilation errors, and I must restart the Visual studio to get the updates to run.
How can I get Edit and Continue to work again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(23)
在“解决方案资源管理器”视图中,右键单击“引用”的每个引用,选择“属性”。在“属性”视图中,将“嵌入互操作类型”字段标记为 False。这对我有用。
In the Solution Explorer view, right-click on each reference of References, choose Properties. In the Properties view, sign False to the field of Embed Interop Types. This works for me.
“编辑并继续”功能不适用于
dynamic
关键字。我尝试删除使用
dynamic
参数的方法,转换后的项目现在可以在 Visual Studio 2010 上运行。Internet研究表明,这是一个已向 Microsoft 报告的错误。下面的链接有更多详细信息:
The Edit and Continue feature does not work with the
dynamic
keyword.I tried to remove the method that uses a
dynamic
parameter, and the converted project now works on Visual Studio 2010.Internet research reveals that is is a bug that has been reported to Microsoft. The link below has more details:
我有一些 Excel 文件
“嵌入互操作类型”== true
。当我将其更改为 false 时,编辑并继续开始工作。I had some Excel file
"embed interop types" == true
. When I changed it to false, edit and continue started working.我昨天使用了微软的分析器,后来我的“编辑并继续”功能消失了。经过几个小时的挫折后,我终于意识到我需要执行 VsPerfCLREnv /globaloff 命令提示符并重新启动我的计算机。现在我有了我的编辑并继续未来。顺便说一句,它与目标平台无关。它可以与设置为任何 CPU 的目标平台一起使用,没有任何麻烦。
I had used Microsoft's profiler yesterday and afterwards my "Edit and continue" feature got away. I finally realized after hours of frustration that I needed to execute VsPerfCLREnv /globaloff command from command prompt and restart my computer. Now I have my Edit and continue future back. It has nothing to do with target platform by the way. It works with target platform set to Any CPU without any hassle.
我知道这篇文章已经过时了,但我最近遇到了这个问题,并且这个 博客文章 向我展示了如何修复它。
这对我多次有效。
I understand this post is old, but I had this issue lately, and this blog post shows me how to fix it.
This works for me multiple times.
我在 Visual Studio 2013 中遇到了这个问题,并且:-
就我而言,我没有嵌入任何互操作类型,我的任何代码也没有
dynamic
关键字,并且我执行了完整的解决方案,但没有成功。然而,我已经运行、调试和重新启动了很多次,所以它可能与内存有关——Visual Studio花了一分多钟才关闭,在此期间磁盘发生了剧烈的抖动(大概是内存分页在玩)。I had this problem in Visual Studio 2013, and :-
In my case, I didn't have any Interop types that were embedded, nor did any of my code have the
dynamic
keyword, and I had performed a full solution clean without success. I had been running, debugging and re-starting many times, however, so it may have had something to do with memory -- it took Visual Studio more than one minute to close, during which time the disk was thrashing (presumably memory paging at play).我会尝试清除 VS 生成的所有文件。因此,我会删除
bin
和obj
目录,并且还会删除*.suo
和*.user 文件。由于这些文件是自动生成的,因此不会影响任何内容(尽管我显然会备份所有文件,以防万一有其他文件被错误地放入其中)。
有时这些文件可能会被损坏(在旧的 VC++ 等中经常发生这种情况),然后 VS 就会开始变得非常有趣。
I'd try cleaning out all the files that are generated by VS. So I'd delete the
bin
andobj
directories and I'd also delete the*.suo
and*.user
files. Since those files are auto-generated this shouldn't affect anything (though I'd obviously make a backup of all files just in case there's some other files that have been put in there by mistake).Sometimes those files can get corrupted (it used to happen quite a lot in the old VC++ etc) and then VS can start acting very funny.
我尝试了上述所有解决方案,但没有一个对我有用。但是,当我在 Visual Studio 中删除 bin 和对象文件夹并再次运行时,它开始工作。
I tried all the above solutions none of them worked for me. However, when I deleted the bin and object folders in visual studio and run again, it start to work.
在我的情况下,有人将对项目输出的引用添加到引用列表中:在解决方案资源管理器中,在 [ProjectName]\References 下查找 [ProjectName*] 并将其删除。
如果项目依赖于其自身副本中的代码,则您无法“编辑并继续”。在警告列表中,如果这是问题的原因,您可能会或可能不会(在较大的项目中更有可能)出现“与导入类型冲突”消息。
In my situation, someone added a Reference to the Project's output into the Reference list: in Solution Explorer look under [ProjectName]\References for [ProjectName*] and remove it.
If the project is relying on code from a copy of itself, you can't 'Edit and Continue'. In the warning list you may or may not (more likely to in a larger project) have 'conflicts with imported type' messages if this is the cause of the problem.
在与 VS2017 社区合作时,我遇到了这个严重的问题:如果您移植现有项目,标签 EmbedInteropTypes 可能尚未出现在 .csproj 文件中,搜索是徒劳的。如果是这种情况,请使用文本编辑器将属性组 Debug|x86(或您使用的任何一个)末尾的标记添加到 .csproj:
before:
after:
这必须使用 all 完成属于解决方案的项目!
working with VS2017 community I had this aggravating problem: if you port an existing project the tag EmbedInteropTypes may not be in the .csproj file yet, a search is futile. If that's the case, add the tag at the end to the property group Debug|x86 (or whichever you use) to the .csproj with a text editor:
before:
after:
This must be done with all projects that belong to the solution!
在 VS2013 中,我必须在调试选项中启用“使用托管兼容模式”。我认为这是因为我有一个引用 .Net 2 程序集的 .Net 4 项目。
对于同一解决方案中的另一个项目,我必须取消选中项目属性中的“定义跟踪常量”。
In VS2013 I had to enable "Use Managed Compatibility Mode" in the debugging options. I think it is because I have a .Net 4 project referencing a .Net 2 assembly.
For another project in the same solution I had to uncheck "Define TRACE constant" in the project properties.
在 Visual Studio 2015 中,我删除了 .vs 文件夹(新样式 .suo 文件所在的位置),删除了所有 bin 和 obj,还卸载了 Resharper 2015。
编辑并继续回来了。
(旁注:智能感知现在几乎立即显示自动完成,而之前需要 2 到 5 秒,可能是 resharper 的错误,也可能无关......)
In Visual Studio 2015, I've deleted the .vs folder (where the new style .suo file is), deleted all bin and obj, and also uninstalled Resharper 2015.
Edit and Continue is back.
(side note: intellisense is now showing autocomplete almost instantly, whereas it was taking 2 to 5 seconds before, maybe resharper's fault, and maybe unrelated...)
对我来说,这是由于 Nuget 未能将包(为 Net Framework 构建)下载到正在引用的 Net Standard 项目而引起的。
Nuget 进入了无限循环(查看输出窗口)。
解决方案是关闭“自动包恢复”设置,请参阅:https://developercommunity.visualstudio.com/content/problem/26638/nuget-infinite-loop.html
访问此设置
工具>>选项> NuGet 包管理器 >一般
For me this was caused by Nuget failing to download a package (built for Net Framework) to a Net Standard project that was being referenced.
Nuget entered an infinite loop (look in the output window).
The solution was to turn off the 'automatic package restore' setting see: https://developercommunity.visualstudio.com/content/problem/26638/nuget-infinite-loop.html
to access this setting
Tools > Options > NuGet Package Manager > General
我必须在“工具”->“工具”中取消选中“启用本机编辑并继续”选项->调试->一般:
I had to uncheck "Enable Native Edit and Continue" in Tools -> Options -> Debugging -> General:
读完上面的内容,我的 UI 项目有 Shell32 且“嵌入互操作类型”== true。我将其更改为 false,然后“编辑并继续”开始工作。
Reading the above, my UI project has Shell32 with "Embed Interop Types" == true. I changed it to false, and "edit and continue" started working.
在“解决方案资源管理器”视图中,右键单击“引用”的每个引用,选择“属性”。在“属性”视图中,将“嵌入互操作类型”字段标记为 False。这对我有用。
In the Solution Explorer view, right-click on each reference of References, choose Properties. In the Properties view, sign False to the field of Embed Interop Types. This worked for me.
对于即使使用 Visual Studio 2017 仍然出现此错误的人,
没有动态/可移植类库/Nuget 包或依赖问题。 Visual Studio 没有突出显示任何错误或警告。
经过几个小时尝试了本文中发布的所有解决方案和 其他线程和网页,对我有用的唯一解决方案是签入、删除工作区并再次
Map&Get
。要删除工作区,
源代码控制
→高级
→工作区
→删除
。我正在使用最新的 Visual Studio 2017 Community,并且在新计算机上进行了相对全新的安装(一周和几个工作时间)。
在上述解决方案之前我测试过的方法没有成功
<_ResolveReferenceDependencies>
设置为true
,如下所述之后,我签入并在另一台运行相同版本的 Visual Studio(2017 Community)的计算机上下载了解决方案。由于我在那里没有遇到“编辑并继续”问题,因此我选择了“工作区”删除。
For who still gets this error even with Visual Studio 2017
No dynamic/Portable Class Libraries/Nuget packages or dependancy problems. No errors or warning highlighted by Visual Studio.
After hours spent trying all the solutions posted in this and other threads and webpages, the only solution that worked for me was to check-in, remove the Workspace and
Map&Get
again.To remove the Workspace,
Source control
→Advanced
→Workspace
→Remove
.I'm using Visual Studio 2017 Community up to date and after a relatively fresh install on a new machine (one week and few work hours).
Methods I've tested with no success prior to the solution above
<_ResolveReferenceDependencies>
totrue
as explained hereAfter this, I made a check-in and downloaded the Solution on another machine running the same version of Visual Studio (2017 Community). As I didn't get the Edit&Continue issue there, I went for the Workspace removal.
就我而言,有效的方法是在调试选项中取消选中“要求源文件与原始版本完全匹配”。 VS 社区 2017 在这里。
In my case, what worked was unchecking "Require source files to exactly match the original version" in Debugging options. VS Community 2017 here.
从我引用的项目的程序集版本中删除 * 解决了我的问题。
来自 Github:
“我使用 [程序集:AssemblyVersion(1.2.3.*”)] 在 VB 和 C# 项目的混合中重现了此问题。一旦 VB 项目引用具有此设置的 C# 项目,事情就会开始崩溃。看起来它也有同样的问题。” -rhuijben
https://github.com com/dotnet/roslyn/issues/28224
(面临被标记的风险,十多年来我们似乎一直受到 VS 编辑和继续问题的困扰。令我震惊的是 Microsoft Visual Studio 团队并不关心发生这种情况时,足以通过提供更详细的信息来帮助开发人员)
Removing the * from the assembly versions of my referenced projects solved the issue for me.
From Github:
"I reproduced this issue on a mix of VB and C# projects with [assembly: AssemblyVersion(1.2.3.*")]. Once a VB project references a C# project with this setting things start collapsing. It looks like it has the same problem the other way around." -rhuijben
https://github.com/dotnet/roslyn/issues/28224
(At risk of being flagged, seems we have been suffering from VS Edit and Continue issues for over a decade. It's shocking to me that the Microsoft Visual Studio team hasn't cared enough to help developers by providing more verbose info when this occurs)
我尝试了以上所有方法,但没有任何效果。这显然是由于启用了一些低级调试选项(查看寄存器...)
工具 ->导入和导出设置->重置所有设置
解决了这个问题
I tried all the above, none worked. It was apparently due to enabling some low-level debugging options (view registers...)
Tools -> Import and Export Settings -> Reset All Settings
resolved it
对我有用的方法类似,但与接受的答案不完全一样。我通过 LINQ 查询创建了一个匿名类型;即
当我将匿名类型更改为元组时,问题就消失了:
What worked for me was similar but not exactly like the accepted answer. I had an anonymous type created as a result of a LINQ query; i.e.
When I changed the anonymous type to a tuple, the problem went away:
我找出了我的项目不允许我在调试模式下继续和编辑的原因之一。
您不能拥有两个具有相同文件名的 C# 文件,即使它们位于不同的文件夹和不同的名称空间中并且可能具有不同的类名。我更改了类名,但仍然没有解决问题。您必须更改 .cs 文件名。
.Net Framework 4.8没有这个问题,所以.net core添加了这个功能。
I figured out one of the reasons my project was not letting me continue and edit while in debug mode.
You can not have two c# files with the same filename even though they are in different folders and different name spaces and might have different class names. I changed the class name and that still didn't fix it. You have to change the .cs filename.
.Net Framework 4.8 doesn't have this issue so .net core added this feature.
在 VS 2015 中,此错误是由我最近安装的 nuGet 包引起的。通过卸载该软件包并重新安装,该错误得到修复。
In VS 2015 this error was caused by a nuGet package I had recently installed. By uninstalling this package and reinstalling, the bug was fixed.