Cannot write code in visual studio during debugging

Hi, I was moved from VS 2013 to 2015 . Therefore, I do not understand too much in detail.

I like VS 2015 because it allows me to evaluate lambda expressions and also allows me to change runtime values.

Scenario:

In some applications (only proven winforms) I can edit the code during debugging and yes, the last code is always executed. i. I do not need to stop and start the program again and again. Yes, this is a very great feature.

But in the case of my first experience with the controller in MVC, I can’t edit the code, and this shows me several reasons.

enter image description here

Can someone explain in what scenarios can I add / remove code during debugging?

Thanks in advance!

+7
c # compiler-warnings visual-studio visual-studio-2015
source share
4 answers

So, after a lot of R&D, I found out that Edit and continue are NOT available for Asp.net . It will be released in the final version of Visual studio 15.

source: https://blogs.msdn.microsoft.com/visualstudioalm/2015/04/29/net-enc-support-for-lambdas-and-other-improvements-in-visual-studio-2015/

0
source share

In your visual studio, go to Tools-> Options-> expand debugging β†’ select Edit and continue, and then select the Enable editing and continue check box. here is an image of this: see screenshot

+1
source share

Usually you cannot edit and continue if you are tied to an already running process, which may be your case if you are tied to a running MVC web project. If something was using Reflection, you also cannot edit it.

+1
source share

I also sometimes saw a similar message that appeared during debugging. I found the following from MSDN regarding code changes during debugging:

The following changes cannot be applied to C# code during a debugging session: - Changes to the current statement or any other active statement. - Active statements include any statements, in functions on the call stack, that were called to get to the current statement. - The current statement is marked by a yellow background in the source window. Other active statements are marked by a shaded background and are read-only. These default colors can be changed in the Options dialog box. - Changing the signature of a type. - Adding an anonymous method that captures a variable that hasn't been captured before. - Adding, removing, or changing attributes. - Adding, removing, or changing using directives. - Adding a foreach, using, or lock around the active statement. 

Additional information: https://msdn.microsoft.com/en-us/library/ms164927.aspx

0
source share

All Articles