即使在启动调试会话之前进行了代码更改,VS 2022 也会出现 ENC0020、ENC0021 错误

Jay*_*man 11 visual-studio visual-studio-2022

有谁知道如何解决这个问题?

我有一个包含多个项目的解决方案,包括:2 个类库、1 个 REST API 服务器、1 个 Web 服务器、2 个 REST API 客户端。我对 REST API 服务器下面的代码进行了更改 - 我将一个函数更改为异步,并将等待添加到对其的调用中。

我在未调试时更改了代码 - 它未处于运行模式。然后我清理了整个解决方案并重建了所有内容。但是,当我按“运行”进行调试时,出现以下错误。

然而 - 代码运行。我可以设置断点并单步执行我添加的新代码,它会执行。不知道为什么它显示错误。

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
Run Code Online (Sandbox Code Playgroud)

ani*_*ite 15

它看起来像是 VS 2022 17.1.3 和 17.1.4 中引入的错误,除了重新启动 VS 之外无需执行任何操作。

  • 我可以确认这一点。有时双击错误列表中的错误可以将其清除,但有时您必须重新启动整个 IDE。对于 IDE 来说,这是非常糟糕的用户体验。但是,如果您重新启动了应用程序,构建仍然可以成功,并且您可以继续工作而无需重新启动 VS 2022。 (5认同)