I've been developing an application in C# (using VS2008) for quite sometime now and about a week ago, 'Edit and Continue' has stopped working for me. I can edit the code while debugging, but any little change that I make to the code now forces me to stop the project and restart it. The message that I get is this:
Modifying a 'method' which contains a lambda expression will prevent the debug session from continuing while edit and continue is enabled.
Oddly, I'm not even using lambda's when this happens. Modifying the same chunk of code last week while in debug mode allowed me to continue with no problems. I've done various searches on the internet to find out what I could have done to cause this change in behavior. The only help I can find on the web is directly related to debugging ASP.NET web projects. However, this portion of my solution is a Windows Forms project.
What could the problem be? Is there a way to fix this? I would greatly appreciate any help.
"Edit and Continue is not supported when you start debugging using Attach to Process. Edit and Continue is not supported for mixed-mode, combined managed and native, debugging, SQL debugging, Compact Framework (Smart Device) projects, debugging on Windows 98, or 64-bit debugging."
edit -- That link says VB, but I'm sure I've had the same problem with mixed native and managed code and 64 bit debugging when using c#.
Just a guess, but perhaps the method you are debugging contains a Type captured from a lambda.
Below is a quote from 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.
It's a long shot, but you may be using LINQ - which is just syntactic sugar for lambda expressions. So maybe you added some LINQ to your code?