VS 2013 ASP.NET can't modify the code while de

2019-06-22 08:14发布

问题:

I'm working with a ASP.NET 2.0 project that has been upgraded from vs 2005->2010->2013.

In vs 2005 and 2010 I can modify the code while debugging, save the changes, and reload the page with the changes applied.

Now in vs 2013 I can't do this. Can't change the code when I hit a breakpoint. Tried to activate all checkboxs in "Edit & Continue" options, but nothing worked.

It's annoying having to stop debugging and recompile the app to debug again the changes.

How can I solve this?

回答1:

FINALLY figured it out. Here are my findings.

To Reproduce: I created 2 vanilla projects:

1) .net 4.0 project with VS2012 (ProjectA) 

2) .net 4.5 project with VS2013 (ProjectB).  

Then opened ProjectA with VS2013 and I couldn't Edit & Continue (E&C).

Resolution:

In VS2013, go into the project's properties on the "Build" tab and uncheck "Optimize Code".

I still don't know why I could Edit & Continue in VS2012 even with "Optimize Code" checked, but in VS2013, it won't work.

Resources:

Here is the link that aided me in locating the problem:

http://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k(vs.debug.ENC.SupportedButNotAvaiable);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.0);k(DevLang-csharp)&rd=true

Hope this helps!



回答2:

I know this is a bit old, but I found the answer today - at least one answer. I'm running Visual Studio 2013 Update 1 and in my case, attempting to debug an MVC 5 application. Switch your target platform (in the Build menu) from Any CPU to either x64 for 64-bit or x86 for 32-bit.

I ran into this today while attempting to debug my MVC 5 application. After reading the release notes for Visual Studio 2013, including the fact that they added the ability in, I was puzzled. I checked my properties and saw that Optimize Code was unchecked while Edit & Continue were checked. The only other debugger marked was ASP.NET. On a hunch, I changed from targeting Any CPU to just targeting x64 under the Build menu. After that, I was able to use Edit and Continue as long as I wasn't attempting to edit lambdas or other items!



回答3:

Find little solution for this case - close all files in solution before run debug. Only files which were closed when debug is started can be edit. Of file is opened when debug is start - edit is not possible.



回答4:

What works for me, is the following:

1) Break point is hit, and I want to change code.

2) Now: Set next statement to somewhere earlier in the current function.

3) Do the change

4) Save / CTRL-s

5) Stepping through the function now includes the change.