编辑并继续功能在 Visual Studio 2010 中停止工作

发布于 2024-10-14 10:10:58 字数 405 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(23

热情消退 2024-10-21 10:10:58

在“解决方案资源管理器”视图中,右键单击“引用”的每个引用,选择“属性”。在“属性”视图中,将“嵌入互操作类型”字段标记为 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.

狼性发作 2024-10-21 10:10:58

“编辑并继续”功能不适用于 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:

温柔少女心 2024-10-21 10:10:58

我有一些 Excel 文件“嵌入互操作类型”== true。当我将其更改为 false 时,编辑并继续开始工作。

I had some Excel file "embed interop types" == true. When I changed it to false, edit and continue started working.

请止步禁区 2024-10-21 10:10:58

我昨天使用了微软的分析器,后来我的“编辑并继续”功能消失了。经过几个小时的挫折后,我终于意识到我需要执行 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.

始终不够爱げ你 2024-10-21 10:10:58

我知道这篇文章已经过时了,但我最近遇到了这个问题,并且这个 博客文章 向我展示了如何修复它。

  • 删除obj文件夹
  • 删除bin文件夹。您可以在删除后将库、数据文件等复制并粘贴回文件夹。
  • 从 VS 中,菜单解决方案 -> 干净的解决方案

这对我多次有效。

I understand this post is old, but I had this issue lately, and this blog post shows me how to fix it.

  • Delete the obj folder
  • Delete the bin folder. You can copy and paste libraries, data files, etc...back to the folder after removal.
  • From VS, menu Solutions -> Clean solution.

This works for me multiple times.

冷血 2024-10-21 10:10:58

我在 Visual Studio 2013 中遇到了这个问题,并且:-

  • 有时只需关闭并重新打开解决方案就可以工作,但是当这不能
  • 重新启动 Visual Studio 时(关闭解决方案、退出 Visual Studio、重新打开 Visual Studio、重新打开解决方案、重新打开解决方案) -尝试使用“编辑并继续”进行调试)修复它。

就我而言,我没有嵌入任何互操作类型,我的任何代码也没有 dynamic 关键字,并且我执行了完整的解决方案,但没有成功。然而,我已经运行、调试和重新启动了很多次,所以它可能与内存有关——Visual Studio花了一分多钟才关闭,在此期间磁盘发生了剧烈的抖动(大概是内存分页在玩)。

I had this problem in Visual Studio 2013, and :-

  • Sometimes just closing and reopening the solution works, but when that doesn't
  • restarting Visual Studio (Close solution, exit Visual Studio, Re-open Visual Studio, re-open solution, re-try debugging with Edit & Continue) fixes it.

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).

兲鉂ぱ嘚淚 2024-10-21 10:10:58

我会尝试清除 VS 生成的所有文件。因此,我会删除 binobj 目录,并且还会删除 *.suo*.user 文件。由于这些文件是自动生成的,因此不会影响任何内容(尽管我显然会备份所有文件,以防万一有其他文件被错误地放入其中)。

有时这些文件可能会被损坏(在旧的 VC++ 等中经常发生这种情况),然后 VS 就会开始变得非常有趣。

I'd try cleaning out all the files that are generated by VS. So I'd delete the bin and obj 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.

诺曦 2024-10-21 10:10:58

我尝试了上述所有解决方案,但没有一个对我有用。但是,当我在 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.

江湖正好 2024-10-21 10:10:58

在我的情况下,有人将对项目输出的引用添加到引用列表中:在解决方案资源管理器中,在 [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.

埋葬我深情 2024-10-21 10:10:58

在与 VS2017 社区合作时,我遇到了这个严重的问题:如果您移植现有项目,标签 EmbedInteropTypes 可能尚未出现在 .csproj 文件中,搜索是徒劳的。如果是这种情况,请使用文本编辑器将属性组 Debug|x86(或您使用的任何一个)末尾的标记添加到 .csproj:

before:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DocumentationFile>bin\Debug\MyProject.XML</DocumentationFile>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>

after:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DocumentationFile>bin\Debug\MyProject.XML</DocumentationFile>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>false</Prefer32Bit>
    <EmbedInteropTypes>false</EmbedInteropTypes>
  </PropertyGroup>

这必须使用 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:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DocumentationFile>bin\Debug\MyProject.XML</DocumentationFile>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>

after:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DocumentationFile>bin\Debug\MyProject.XML</DocumentationFile>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>false</Prefer32Bit>
    <EmbedInteropTypes>false</EmbedInteropTypes>
  </PropertyGroup>

This must be done with all projects that belong to the solution!

星軌x 2024-10-21 10:10:58

在 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.

握住我的手 2024-10-21 10:10:58

在 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...)

格子衫的從容 2024-10-21 10:10:58

对我来说,这是由于 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

太阳男子 2024-10-21 10:10:58

我必须在“工具”->“工具”中取消选中“启用本机编辑并继续”选项->调试->一般:

在此输入图像描述

I had to uncheck "Enable Native Edit and Continue" in Tools -> Options -> Debugging -> General:

enter image description here

和我恋爱吧 2024-10-21 10:10:58

读完上面的内容,我的 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.

沙沙粒小 2024-10-21 10:10:58

在“解决方案资源管理器”视图中,右键单击“引用”的每个引用,选择“属性”。在“属性”视图中,将“嵌入互操作类型”字段标记为 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.

朦胧时间 2024-10-21 10:10:58

对于即使使用 Visual Studio 2017 仍然出现此错误的人,

没有动态/可移植类库/Nuget 包或依赖问题。 Visual Studio 没有突出显示任何错误或警告。

经过几个小时尝试了本文中发布的所有解决方案和 其他线程和网页,对我有用的唯一解决方案是签入、删除工作区并再次Map&Get

要删除工作区,源代码控制高级工作区删除

我正在使用最新的 Visual Studio 2017 Community,并且在新计算机上进行了相对全新的安装(一周和几个工作时间)。


在上述解决方案之前我测试过的方法没有成功

  • 确保编辑并删除在 Visual Studio 选项中启用了“继续”。取消勾选并再次勾选它
  • 删除解决方案中所有项目的 bin 和 obj
  • 清理并重新构建全部,重新启动 VS / 重新启动结合上述
  • 检查项目的编译选项和 Nuget 包和 dll 兼容性,灵感来自 this
  • 以各种组合卸载项目以测试依赖性问题或其他问题(受到这个的启发)
  • 删除解决方案并重新下载(不删除工作区)
  • 签署 False 以嵌入互操作类型
  • <_ResolveReferenceDependencies> 设置为 true,如下所述
  • /stackoverflow.com/questions/20324080/visual-studio-2013-net-4-5-1-edit-and-continue-64-bit-not-working/20344017#20344017 ">此处 上面重新启动 VS 并重新启动

之后,我签入并在另一台运行相同版本的 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 controlAdvancedWorkspaceRemove.

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

  • Made sure Edit & Continue was enabled in Visual Studio options. Untick and tick it back again
  • Deleting bin and obj for all project in solution
  • Clean and Rebuild all, restart VS / reboot in combination to the above
  • Checking compile options and Nuget packages and dll compatibility for the projects, inspired by this
  • Unloading the projects in various combinations to test dependancy problems or other issues (inspired by this)
  • Deleting solution an re-downloading it (without removing the Workspace)
  • Sign False to Embed Interop Types
  • Set <_ResolveReferenceDependencies> to true as explained here
  • Combinations of the above with restart of VS and reboots

After 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.

笑梦风尘 2024-10-21 10:10:58

就我而言,有效的方法是在调试选项中取消选中“要求源文件与原始版本完全匹配”。 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.

番薯 2024-10-21 10:10:58

从我引用的项目的程序集版本中删除 * 解决了我的问题。

来自 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)

等风也等你 2024-10-21 10:10:58

我尝试了以上所有方法,但没有任何效果。这显然是由于启用了一些低级调试选项(查看寄存器...)

工具 ->导入和导出设置->重置所有设置

解决了这个问题

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

聊慰 2024-10-21 10:10:58

对我有用的方法类似,但与接受的答案不完全一样。我通过 LINQ 查询创建了一个匿名类型;即

var thingy = (from thing in things select new { thing.Property1, thing.Property2 }).First();

当我将匿名类型更改为元组时,问题就消失了:

var (thing1, thing2) = (from thing in things select (thing.Property1, thing.Property2)).First();

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.

var thingy = (from thing in things select new { thing.Property1, thing.Property2 }).First();

When I changed the anonymous type to a tuple, the problem went away:

var (thing1, thing2) = (from thing in things select (thing.Property1, thing.Property2)).First();
送你一个梦 2024-10-21 10:10:58

我找出了我的项目不允许我在调试模式下继续和编辑的原因之一。
您不能拥有两个具有相同文件名的 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.

最终幸福 2024-10-21 10:10:58

在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文