UPDATE: The desired function was added in Visual Studio 2015 after many user requests for this function. This answer and question is now out of date.
Is there any way to avoid this error?
Yes. Remove the lambda from the method. Or do not edit the method.
Is there a way to avoid this error by not removing the lambda from the method and still editing the method?
No. The error message does not apply to you.
The reason for this, if you're interested, is that lambdas are compiled as methods of a nested class, and local variables that are closed by lambdas become fields of this class. The edit-and-continue function overwrites the current method on the fly when you edit it, but even simple changes can lead to complex changes for these nested classes. Instead of spending a lot of effort in making the E&C work for this scenario, and thus stealing resources from other, more valuable functions, the debugger team simply made it illegal.
source share