工程编译没有任何报错, 但是 在代码编辑器中, Resharper 始终提示代码有错误.
解决方案来源: https://stackoverflow.com/questions/17703004/visual-studio-displaying-errors-even-if-projects-build
Here's a collection of popular answers. Upvote the OP of the answer if it helped you:
As @Mike Fuchs mentioned, try the following operations:
In menu, Build > Clean Solution
then build it:
In menu, Build > Build Solution
and finally Refresh:
As @Pixel mentioned, try the following sequence of operations:
- Clean the solution
- Close Visual Studio
- Open Visual Studio
- Build solution
If you have ReSharper, try emptying the ReSharper cache:
In menu, ReSharper > Options > Environment > General > Clear Caches
and disabling and re-enabling ReSharper:
In menu, Tools > Options > ReSharper > General > Suspend / Restore
As @Neolisk mentioned, deleting the .suo file might solve your problem. For Visual Studio 2015, the file is located in:
[Path of Solution]/.vs/[Solution Name]/v14/.suo
And for Visual Studio 2017:
[Path of Solution]/.vs/[Solution Name]/v15/.suo
Note that the .vs directory is hidden.
As @TTT mentioned, try unloading the project that causes problems:
In Solution Explorer, right-click on project, Unload Project.
And re-loading it
In Solution Explorer, right-click on project, Reload Project.
As @Guilherme mentioned, try removing and adding the reference to "Microsoft.CSharp" from the projects that have problems.
In Solution Explorer, expand the project, expand "References", right-click on "Microsoft.CSharp" and Remove.
Then, right-click on References > Add Reference, select "Microsoft.CSharp" from the list and click OK