我用 C#(使用 VS2008)开发应用程序已经有一段时间了,大约一周前,“编辑并继续”对我来说已经停止工作了。我可以在调试时编辑代码,但现在我对代码所做的任何小改动都会迫使我停止项目并重新启动它。我收到的消息是这样的:
修改包含 lambda 表达式的“方法”将阻止调试 session 在启用编辑和继续时继续。
奇怪的是,发生这种情况时我什至没有使用 lambda。上周在 Debug模式下修改相同的代码块让我继续没有问题。我在 Internet 上进行了各种搜索,以找出我可以做些什么来导致这种行为改变。我在 Web 上可以找到的唯一帮助与调试 ASP.NET Web 项目直接相关。但是,我的这部分解决方案是一个 Windows 窗体项目。
可能是什么问题?有没有办法来解决这个问题?如果有任何帮助,我将不胜感激。
只是一个猜测,但也许您正在调试的方法包含从 lambda 捕获的类型。
以下引自 here .
... EnC [EditAndContinue] can modify
IL, but not types--that is, it can't
add fields or methods to a type,
remove a type, or create a new one.
Lambda expressions that capture local
variables can result in the creation
of hidden types under the hood.
Modifying a method containing a lambda
expression could change the locals
that are captured, which would require
changing the hidden type. The same
limitation has existed with anonymous
methods since C# 2.0 and VS 2005.