Jay Imerman
Jay Imerman

Reputation: 4600

VS 2022 errors ENC0020, ENC0021 even though code changes were made prior to starting debug session

Does anyone know how to solve this problem?

I have a solution with multiple projects, including: 2 Class Libraries, 1 REST API server, 1 Web server, 2 REST API clients. I made a change in the code underneath REST API server - I changed a function to async, and added await to the calls to it.

I made the code changes while NOT debugging - it was not in run mode. I then cleaned the entire solution and did a rebuild all. However, when I press Run to debug, I get the following errors.

HOWEVER - the code runs. I can set breakpoints and step through the new code I added, it executes. No idea why it is showing the errors.

Severity    Code    Description Project File    Line    Suppression State
Error   ENC0020 Renaming method requires restarting the application.    RESTServer  E:\Data\dotNetDev\ea\RESTServer\RESTServer\Models\AccountModel.cs   231 Active
Error   ENC0021 Adding parameter requires restarting the application.   .Core   E:\Data\dotNetDev\ea\RESTServer\.Core\System-email.cs   45  Active
Error   ENC0021 Adding await expression requires restarting the application.    RESTServer  E:\Data\dotNetDev\ea\RESTServer\RESTServer\Controllers\AccountController.cs 161 Active
Error   ENC0021 Adding await expression requires restarting the application.    RESTServer  E:\Data\dotNetDev\ea\RESTServer\RESTServer\Controllers\AccountController.cs 212 Active
Error   ENC0021 Adding await expression requires restarting the application.    RESTServer  E:\Data\dotNetDev\ea\RESTServer\RESTServer\Controllers\AccountController.cs 260 Active

Upvotes: 15

Views: 10818

Answers (7)

AyrA
AyrA

Reputation: 863

In my case it is caused by IIS. Simply exiting the IIS development server in the tray icon allows me to debug again. Still annoying, but faster than a VS restart.

Upvotes: 0

calovey
calovey

Reputation: 41

I had same problem with version 17.0.6 and I updated version 17.3.4 now its fine.

Upvotes: 2

Manoj
Manoj

Reputation: 6000

In my case this was due to code error in "Razor view". I accidently deleted first line in razor view @model xxxx and started receiving lots of repeated error messages (one error for each use of Model.xx)

Error ENC0020 Renaming method requires restarting the application.

double click the error and review opened razor file for code issues.

Upvotes: 0

Henrik Erlandsson
Henrik Erlandsson

Reputation: 3830

As per the accepted answer, it seems to be a bug. But builds can still succeed, so that you can continue developing without having to restart the entire IDE.

The error may stay shown in the Error List but not be an actual error, as long as you have fixed the error.

Upvotes: 0

anisite
anisite

Reputation: 538

It's look like a bug introduced in VS 2022 17.1.3 and 17.1.4, nothing to do except restart VS.

Upvotes: 18

notidaho
notidaho

Reputation: 588

A Rebuild of the Solution worked for me and removed the error.

I suspect something was stuck in debug mode.

Upvotes: 0

Jay Imerman
Jay Imerman

Reputation: 4600

Apparently closing and relaunching Visual Studio 2022 solved the problem.

Upvotes: 1

Related Questions