ENC1003 C# Changes made in project will not be applied while the application is running

12,539

Solution 1

Try to get the Lastest Version of your Visual Studio and try again, If Persist, Install Visual Studio 2019 v16.4 Preview 2.

Also Check out the following content>> https://developercommunity.visualstudio.com/content/problem/601258/edits-were-made-to-the-code-which-cannot-be-applie.html. You can also track this same issue on ASP.NET Github: https://github.com/aspnet/AspNetCore/issues/13284. We already have a fix for it, which will be available on Visual Studio 16.4 Preview 2

I was facing the same problem in my Visual Studio 2019, and therefore I had to update VS to the latest version and I was good to go.

Hope helps someone :) :)

Solution 2

You can go to build options and select the option to build solution (build->build solution), this should solve the problem and you will able to continue your project in solution mode.

Share:
12,539
Jez
Author by

Jez

Long-time coder, with some interest in French and Philosophy. I sometimes hang out in the English Language & Usage chatroom. Check out my Firefox addons! :-)

Updated on June 06, 2022

Comments

  • Jez
    Jez almost 2 years

    I am getting this incredibly annoying warning for every C# file in my ASP.NET Core project when I debug it after hitting F5:

    Warning screenshot

    Because this error appears only during runtime (not during build), I can't even suppress it using the "Suppress warnings" box in the project properties. I've tried putting 1003 and ENC1003 in there and it still appears, cluttering up my warnings window. Does anyone know why this thing is appearing and how I can get rid of it?

    UPDATE: It doesn't fix the fundamental problem which is that the warning is generated in the first place, but I've found a way to suppress it. Create a GlobalSuppressions.cs file at the project root, and add the line:

    [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(null, "ENC1003")]
    

    Related Github issue: https://github.com/aspnet/AspNetCore/issues/13284

    • Tseng
      Tseng almost 5 years
      You editing code in debug mode (pausing, change code, continue execution)? Some changes can't be done until a appication restarts, thats why it tells you. This is especially true for stuff where scopes are involved iirc and capturing of variables (means lambda methods))
    • Tseng
      Tseng almost 5 years
      Other than that, if you don't use Edit and Continue (=ENC), check your extensions. Turn off all Extensions or start VS in safe mode and see if it still appears
    • Jez
      Jez almost 5 years
      @Tseng No, this warning happens even if I don't edit code. I always get it.
    • Tseng
      Tseng almost 5 years
      Well, then test in safe mode. May be an extension causing it
    • DaveEP
      DaveEP over 4 years
      I just updated to 16.3.0 and have started seeing this error. F5, run the code, STOP the debugging session. Make a simple change to file A and hit F5 to start again. This warning then appears for 10-15 other files in which I've made NO changes at all, If I hit a break point it then it often tells me tells me I can't continue without rebuilding. This is not just in .net core, but also WPF apps.
    • ccalboni
      ccalboni over 4 years
      Confirmed for Windows Forms too. Appeared after installing 16.3.2. I extensively use Edit&Continue and I'm aware of changes that need a restart to be compiled, but this happens also without any change to the code, right after a run: after this messages appear, I can't Edit&Continue anymore. Pretty annoying.
    • tig
      tig over 4 years
      I have this happening in a WinForms app in 16.32.2. Clearly a bug in VS as this only started after upgrading to the latest build.
    • gridtrak
      gridtrak over 4 years
      I am experiencing this problem in latest release update 16.4.1. I used to add comments to my code all the time while debugging. Now if I do that, I get the warning and then stepping (F10 or F11) is unreliable. I seem to remember having no problems with this until 16.3.x.
    • rollsch
      rollsch about 3 years
      This error occurs for me even when the application is not running! I can't get it to go away unless I restart Visual Studio.
    • Kirk Woll
      Kirk Woll about 2 years
      Still happening with VS2022. @Jez, I find your solution to suppress it sound advice as I literally never find any value whatsoever in these stupid warnings. I'd recommend posting that as an answer as I'd upvote it.
  • Jez
    Jez almost 5 years
    No, it doesn't.
  • Jez
    Jez over 4 years
    This is probably the right answer. They say it's been fixed in 16.4. I'm gonna download 16.4 when it becomes available as a non-preview and just check that it's fixed.
  • Michael
    Michael over 4 years
    I have 16.4.2 and it still happens to me.. unless im missing an option I can toggle?
  • Aashishkebab
    Aashishkebab about 4 years
    "I would argue..." it doesn't matter what your opinion is, OP is asking for a solution on this.
  • Aashishkebab
    Aashishkebab about 4 years
    The fix is for a bug that caused it to appear even not during runtime. OP doesn't want it showing up during runtime either.
  • Watachiaieto
    Watachiaieto about 4 years
    @Aashishkebab The OP's question was not very clear. They mention that they "Don't know where it comes from" and that it "won't go away". When what they really should have made clear in their question was "After hitting debug and making no changes, the warnings appear". It would have lead me to help them suppress the warnings that should not exist, rather then tell them what the warning means and why it is important.
  • Aashishkebab
    Aashishkebab about 4 years
    @Watachiaieto the way I read this, OP launches the application, makes some changes to the code while the application is still running, and then receives this warning. I've experienced the same, and it's very annoying given that I as the developer know that I've modified the code and that it won't reflect in the running application.
  • Watachiaieto
    Watachiaieto almost 4 years
    @Aashishkebab The OP was (not very clearly) complaining about a bug where EVERY line of code had this warning. It may be the case that the language you program in the changes will not be applied until you relaunch the application, but that is not the case for all languages, and may not be the case for you language forever. It is an implementation needed of JIT compilation. In the visual studio C# implementation, some of my code is implemented after making changes DURING run time, while some are not. Trust your IDE to know whats best - after it, it compiles your code ;)
  • Aashishkebab
    Aashishkebab almost 4 years
    @Watachiaieto I program in C#. Sometimes you can "Apply Code Changes," and sometimes I can't. I don't trust Visual Studio as far as I can't throw it. Other IDEs like IntelliJ are a lot better, but I can't do WPF development on it.