Sometimes ReSharper incorrectly identifies success

2019-08-22 05:44发布

问题:

Sometimes, after updating NuGets, ReSharper marks specific lines as errors, even though the solution builds, due to inability to recognize the type in use e.g. marks methods or properties in red, marks usage of object in red. In these cases the ReSharper intellisense is broken too.

In these cases sometimes reanalyzing all files in the "Errors in Solution" window and cleaning, closing Visual Studio, deleting the .suo file, reopening Visual Studio and Solution and building does not help.

Is there any way to fix this?

回答1:

I encountered this a few times, in all these cases, editing the .csproj file with the code misidentified as erroneous and modifying the references to the assemblies with the types not recognized from:

<Reference Include="AssemblyNameGoesHere, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\AssemblyNameGoesHere.1.3.0\lib\net45\AssemblyNameGoesHere.dll</HintPath>
  <Private>True</Private>
</Reference>

to

<Reference Include="AssemblyNameGoesHere">
  <HintPath>..\packages\AssemblyNameGoesHere.1.3.0\lib\net45\AssemblyNameGoesHere.dll</HintPath>
</Reference>

Solved this issue.

I reached this solution by comparing the .csproj files of the project with the "errors" other projects in the solution containing similar code that is was not marked as erroneous by ReSharper.