3

On 2 different computers (both Windows 10 Pro fully patched), I am running Visual Studio 2019 Pro (also fully patched).

If I create a new dummy Windows Forms project (VB or C#), edit and continue works great.

If I open a solution (composed of 25 projects) I have been working for years on the same computers, edit and continue is not working.

So what I understand is that there are settings on a per-solution basis that would affect the edit-and-continue. Of course, I build in Debug mode (not Release).

If I look at Tools-Options-Debugging-General, "Enable Edit and continue" is enabled. Also Tools-Options-Debugging-Just in time, the 3 options are selected.

Do you know what it could be?

emoreau99
  • 634
  • 6
  • 16

2 Answers2

5

Edit-and-continue not working in VS2019 Pro (WinForms app)

Please try the following suggestions:

Suggestion

1) please make sure that you have uncheck the option Use Managed Compatibility Mode under Tools-->Options-->Debugging-->General

and also uncheck Require source file to exactly match the original version.

2) please uncheck the option Edit and Continue first, then close your old solution,

delete .vs hidden folder in the solution folder, every bin and obj folder in the solution.

After that, restart your solution, check the option Edit and Continue,then test again.

3) Right-click on every project-->Properties-->Build-->Advanced--> make sure that you set Debugging Information to full.

4) add this node in every xxx.csproj/xxx.vbproj files of your projects in the whole solution:

<PropertyGroup>
    <EmbedInteropTypes>false</EmbedInteropTypes>
</PropertyGroup>

Besides, since the structure of old projects from previous VS is different from the new VS2019. So it might have some problems.

So creating a new solution in VS2019 and then migrate the content from the old ones into the new projects might be a good choice. I think you could have a try.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Hi Perry. I have done all that and I still can't get the edit and continue to work. Some more elements I can add are that VS let me edit the code when on a breakpoint, but I see that the yellow and redish backgrounds are not covering the full line of code (surely meaning that it is not considering the modifications). Also, if I hit F10 on the line just modified and try to rerun the same line by moving the yellow arrow on that line I get an error popup saying: "Unable to set the next statement. There was a failure while applying code changes and the code context could not be determined." – emoreau99 Jul 15 '20 at 15:35
  • Please try to check the option `Enable property evaluation and other implicit function calls` and `Use the legacy C# and VB expression evaluators`under `Tools`-->`Options`->`Debugging`->`General` then run your project to test again. – Mr Qian Jul 16 '20 at 10:00
  • Also, clr exceptions may have some possibilities, try to [this issue](https://social.msdn.microsoft.com/Forums/vstudio/en-US/c72323de-f551-4800-bbdf-d1f30bb1f8ea/set-next-statement-not-working-in-vs2015-debugger?forum=vsdebug). – Mr Qian Jul 16 '20 at 10:04
  • Hi Perry. Thanks for helping. "Enable property evaluation and other implicit function calls" was already checked. I can't find "Use the legacy C# and VB expression evaluators". I already tried the clr exceptions. Still no luck – emoreau99 Jul 16 '20 at 12:28
  • I have found "Use the legacy C# and VB expression evaluators" in VS2017. I can't find it in VS2019. Speaking of VS2017, I have it installed on 1 of the 2 computers and edit & continue on that same solution is not working – emoreau99 Jul 16 '20 at 12:36
  • Just found something really strange. When debugging, if I edit the code and hit F10, I see a new warning shown in the "error list" panel saying "Severity Code Description Project File Line Suppression State Warning ENC1006 Unable to read source file 'C:\_Dev\FGLWorkspaces\FGLBackOffice\FGLApps2008\FGLApp2020\Form1.vb' or the PDB built for the containing project. Any changes made to this file while debugging won't be applied until its content matches the built source". Does it gives you any other ideas? – emoreau99 Jul 16 '20 at 17:36
  • In my case it was due to the Fody/Costura packages. I had to comment-out "Costura" in FodyWeavers.xml, so Edit and Continue started working again. – sun2sirius Sep 15 '21 at 22:45
2

I found the issue. I am using PostSharp and that is messing with the edit-and-continue feature of VS2019. I wrote to the PostSharp support team waiting on what they have to say!

emoreau99
  • 634
  • 6
  • 16