Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper reference errors between .netcore / .netstandard projects

I've got two projects in Visual Studio, where classes in the first one refers to classes in the second. The first project is a .netcore app, with the following in it's project file:

<TargetFramework>netcoreapp2.0</TargetFramework>

The second project has multiple target frameworks:

<TargetFrameworks>netstandard2.0;net461;net462</TargetFrameworks>

Both projects compile and work fine, but classes located in the the second project appear red in code in the first project, as if there is a reference error. For context, here's a generic example:

enter image description here

The smudged out red part is a class defined in the other project. I can navigate to it (using F12 / "go to definition" or ctrl + click), but when I hover the cursor above the red text, is says

Cannot resolve symbol 'MyClassName'

So just to be absolutely clear: Everything still works - it's just that Resharper erroneously reports a reference error her, and that bugs me.

How do I know resharper is causing this? Because if I disable Resharper (Tools -> Options, search for resharper and click "suspend"), the error disappears:

enter image description here

Enabling Reshaper again causes the error to return immediately.

I suspect this has something to do with the types of projects (i.e. their target frameworks), but I haven't been able to figure it out exactly.

Any ideas about how get rid of these errors?

like image 809
Kjartan Avatar asked Feb 21 '18 09:02

Kjartan


Video Answer


1 Answers

Resharper shenanigans

Solution 1

Tools->Options->ReSharper 
  • Suspend Now
  • Resume

It refreshes the cache and/or some other dark magic


Solution 2

You could try clearing the ReSharper cache implicitly

ReSharper->Options->Environment->General 
  • Clear Caches.

Solution 3

You can also try unloading and then reloading the project.

Solution Explorer->Right Click
  • Unload Project
  • Reload Project

Solution 4

As a last resort you can try to delete the solution cache manually

%LOCALAPPDATA%\JetBrains\Transient\ReSharperPlatformVsXX\vXX\SolutionCaches\
like image 189
TheGeneral Avatar answered Oct 17 '22 14:10

TheGeneral