24

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

Jez
  • 27,951
  • 32
  • 136
  • 233
  • 1
    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 Aug 20 '19 at 14:24
  • Other than that, if you don't use [Edit and Continue](https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-use-edit-and-continue-csharp?view=vs-2019) (=ENC), check your extensions. Turn off all Extensions or start VS in [safe mode](https://learn.microsoft.com/en-us/visualstudio/ide/reference/safemode-devenv-exe?view=vs-2019) and see if it still appears – Tseng Aug 20 '19 at 14:30
  • 1
    @Tseng No, this warning happens even if I don't edit code. I always get it. – Jez Aug 20 '19 at 14:43
  • Well, then test in safe mode. May be an extension causing it – Tseng Aug 20 '19 at 14:44
  • 2
    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. – DaveEP Sep 25 '19 at 16:47
  • 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. – ccalboni Oct 08 '19 at 08:32
  • 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. – tig Oct 10 '19 at 21:00
  • 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. – gridtrak Dec 17 '19 at 17:06
  • 3
    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. – rollsch Apr 15 '21 at 04:57
  • 1
    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. – Kirk Woll May 05 '22 at 19:00

4 Answers4

2

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 :) :)

Community
  • 1
  • 1
PatsonLeaner
  • 1,230
  • 15
  • 26
  • 1
    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. – Jez Oct 21 '19 at 08:13
  • I have 16.4.2 and it still happens to me.. unless im missing an option I can toggle? – Michael Jan 04 '20 at 13:48
  • 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. – Aashishkebab May 04 '20 at 17:43
  • I still see this error in 2022 version. Why? – Lê Duy Thứ Mar 21 '23 at 02:51
1

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.

Ali
  • 2,702
  • 3
  • 32
  • 54
Milan
  • 46
  • 7
1

I had this problem also in Visual Studio 2022 (17.0.5) running API projects. Restarting Visual Studio helps.

Anton Kalcik
  • 2,107
  • 1
  • 25
  • 43
0

In the past, while debugging UAP apps, if I edit the code while the app is running it will let me know that it needs to recompile the whole application. (Usually when adding some sort of static variable or removing a function etc... Tht in and of itself is not a bug.

The bug is that when I STOP debugging, the error remains until I restart the IDE.

I would argue that suppressing the warning is a horrible idea - It means that you have no way of knowing if the code changes you made during debug were implemented.

Instead, try restarting the IDE and doing a clean and build. I don't remember what I do to make the error go away anymore, as I have not experiences this bug in at least 8 months.

Watachiaieto
  • 417
  • 3
  • 10
  • 1
    No, it doesn't. – Jez Aug 20 '19 at 14:43
  • "I would argue..." it doesn't matter what your opinion is, OP is asking for a solution on this. – Aashishkebab May 04 '20 at 17:42
  • @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. – Watachiaieto May 15 '20 at 22:54
  • 2
    @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. – Aashishkebab May 16 '20 at 23:24
  • @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 ;) – Watachiaieto May 30 '20 at 13:21
  • @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. – Aashishkebab May 31 '20 at 15:22