How to make ReSharper re-evaluate its assembly reference highlighting
T

15

191

I am creating a Prism Project Template, and the template works great. But after I create a project with the template some of the files look like this:

Bad References

Despite appearances, everything is just fine.

If I do a Rebuild All I see that the solution builds with no errors:

Rebuilt

But the rebuild all does not get rid of the "errors" that are showing in the editor window. (Note that the actual error window does not show any errors.)

I can clean, rebuild, close and open files, and it will not fix the highlighting.

However, if I close the solution and re-open it, all is well:

Works After Reload

My Question:

Ideally there would be a way for my template or my IWizard to tell ReSharper to reload the references for the highlighting.

I know I can turn ReSharper off and then on again and that will fix it, but I would rather not do that.

Is there a ReSharper command that just refreshes this stuff?

Tila answered 21/3, 2012 at 5:29 Comment(7)
Are you using ReSharper?Landlocked
@JohnSaunders - yes, 5.1Tila
I've seen ReSharper do this, so it may be a ReSharper bug, not a VS bug. I just recently saw this with version 6.1.Landlocked
@JohnSaunders - I confirmed that this is a ReSharper issue. I edited my question to re-target it towards ReSharper. Thanks for pointing me in the right direction!Tila
What versions of Prism, WPF/SL/WinPhone are you using in your project?Denunciation
@gorohoroh - I am using the latest Released versions of Prism and WPF. (My template is just for WPF).Tila
It's a bug in Visual Studio and Resharper, a classic stalemate. See youtrack.jetbrains.com/issue/RSRP-329698Hepatitis
P
220

Except for reinstalling, the only way to successfully clear the caches is to delete the files manually from your AppData directory.

Delete the solution folder that's giving you grief in the following locations:

  • %LOCALAPPDATA%\JetBrains\ReSharper\v7.1\SolutionCaches\
  • %LOCALAPPDATA%\JetBrains\Transient\ReSharperPlatformVsXX\vXX\SolutionCaches\ for newer versions.

Note that the version numbers in the paths may be different depending on the ReSharper version that is installed.

The XX in vXX and VsXX represents any number, because there might be multiple folders where the solution cache is stored.

Prescriptible answered 23/7, 2013 at 9:20 Comment(12)
This path might be different depending on your Caches configuration. (See Resharper>Options>General)Hying
@PeterMunnings - While that may work, it is not a command like I was looking for. A manual step kind of defeats the purpose.Tila
Fair enough - but it definitely fixes the problem you're facing (and not just you...)Schaller
True, there is no specific command, but this can become an automated process by wrapping the delete in a batch file and importing that command into Visual Studio. You can then assign a shortcut to it and then call ReSharper specific things such as Reanalyze all files.Prescriptible
The answer is correct. Close all your visual studio instances, delete %LOCALAPPDATA%\JetBrains\ReSharper\ [installed_version] \SolutionCaches.Hyperpituitarism
Doesn't work for me with version 8.1 of Resharper. I still have the problem described.Sexology
Where is this folder in the latest version of resharper? I can't seem to find the folder SolutionCaches.Ellieellinger
@Ellieellinger in ReSharper 9, with the introduction of the ReSharper Platform, it's been moved to %localappdata%\JetBrains\Transient\ReSharperPlatformVs12\v01\SolutionCaches (as @brgerner mentions, you may want to click the Clear Caches button first before going this route)Bamberger
You can use Resharper -> General -> Clear Caches to clear the caches regardless of your cache location. You will need to restart Visual Studio after clearing your cacheAberrant
Work for me, Resharper 8.1 don´t have folder %LOCALAPPDATA%\JetBrains\Transient\......Var
Did not work me for me. VS 2013, Resharper Ultimate 2015.2Tibbs
After clearing the cache and restarting Visual Studio. Make sure you clean the solution and rebuild the solution as well. After doing the clean and rebuild it worked for me.Overtire
E
99

Try unloading and then reloading the project.

To unload the project, right-click the project in the solution explorer, and select Unload Project. Then, right-click the project again and select Reload Project.

The issue continues to occur occasionally with the latest versions of ReSharper, but the fix seems to work for every version.

Entity answered 3/12, 2012 at 22:16 Comment(1)
Looks like the reload causes resharper to re-scan. This seems easier to me than hunting for caches in the file explorer.Wernick
P
75

You could try clearing the ReSharper cache via menu ReSharperOptionsEnvironment/General → button Clear Caches.

Postmillennialism answered 21/3, 2012 at 9:57 Comment(6)
Alas, it still did not fix it... Thanks for the idea though.Tila
After that, you need to restart visual studio. Then it will work.Yamashita
Did not work for me, even after restarting visual studio. Thanks however.Sexology
Happened to me after downgrading a nuget package then upgrading again. Used this hint to fix.Callous
Works best if you close visual studio then do msbuild yourSolution.sln /t:clean then clean all resharper caches, save and then reopen your solution.Uninterrupted
After clearing the cache and restarting Visual Studio. Make sure you clean the solution and rebuild the solution as well. After doing the clean and rebuild it worked for me.Overtire
S
15

This worked for me. There is no need to reload projects. You can do this from within Visual Studio.

  1. Clear the ReSharper cache via ReSharper, Options, General, click 'Clear Caches'.

    Resharper Options

    Resharper Clear Caches

  2. ReSharper, Windows, select 'Solution Errors'. This will launch the Solution Errors window. At the top of this window, click the button to 'Reanalyze Files With Errors/Warnings'.

    ResharperWindows

    Reanalyze Files With Errors

Shack answered 22/10, 2014 at 16:30 Comment(2)
Worked with R# 10.0.2, without having to restart VS.Ruelu
This worked for me, although I did have to restart VSChrissy
D
6

Open ReSharper - Options - Environment - General, scroll down to Msbuild access and select Obtain data from msbuild after each compilation.

This worked for me, using ReSharper 10.0.1 with ReSharper Build.

Daytime answered 27/1, 2016 at 10:53 Comment(1)
I also cleaned the solution and rebuild it. Then I can switch back to the previous Msbuild access when it's workingValentinvalentina
B
5

Go to ReSharper → WindowsSolution Errors Window, and you will get an overview of the errors in your solution. There, you can click the button Reanalyze Files With Errors.

If you want, you can assign a shortcut to this. Go to ToolsOptionsKeyboard, and search for "Reanalyze". You can assign a keyboard shortcut to either 'ReSharper_ErrorsView_ReanalyzeAllFiles' or 'ReSharper_ErrorsView_ReanalyzeFilesWithErrors'.

Brewing answered 7/6, 2012 at 8:13 Comment(3)
i am facing similar issue, and it does not fix.Mountbatten
I just tired this too. It did not fix the issue. Resharper still marked errors, but it all compiled fine. Unloading and re-loading the project is the only workaround I can find. (Though I am told it is fixed in the latest version of resharper)Tila
Very Useful! I had the same issue with VS 2019, and Resharper 2019.3, but in fact it was NOT an issue. The fact that the project builds does not necessary mean that Resharper will not find errors. In my case there were some errors in some xml test files in my NUnit project. This solution quickly found the filesPacorro
S
3

I have a similar issue with nuget packages and I found a most weird workaround: select the reference in project reference list and press 'F4'. Somehow properties window appearance causes resharper to reevaluate available references...

Save answered 23/3, 2017 at 14:11 Comment(2)
I had no luck with all the "clean cache" tips. Then i tried this and it almost helped. My workaround was: Find the project with the issue - open the references - select the reference that was flagged as unknown by R# - Press F4 - change something in the properties, like "copy local from true to false, then back to true"Filippo
I had a similar fix. I had to actually remove the reference from my project and re-add it. None of the other solutions worked for me.Gisarme
P
2

Go to ReSharper → OptionsGeneral and click Clear Caches. (I have 8.2, so if you're on a different version it may be elsewhere.)

You'll then need to re-open your solution, and ReSharper will re-analyse everything.

Punishable answered 3/6, 2014 at 9:41 Comment(1)
Worked for me, thank you. I had tons of projects in my solution and didnt want to unload/reload them all one by one :p Not sure why you got a downvote though.Investment
C
2

I am not certain this is the same root cause, but I discovered that, within the ReSharper options, "Use MsBuild" was checked and I got all sorts of erroneous errors reported. Try checking "ReSharper->Options->General" and see what state the "Use MsBuild" check is in.

Cruce answered 6/8, 2014 at 22:59 Comment(0)
W
1

Run the following code in a command prompt. Then solve the ReSharper issue...

del /q/f/s %TEMP%\*
Wasteland answered 20/9, 2016 at 5:16 Comment(0)
E
0

The only thing that helped me is: Unistall and than Install Resharper again (Repair didn't work)

Visual Studio 2010 SP1, ReSharper 7.1.3000.2254

Exasperate answered 11/6, 2013 at 12:30 Comment(0)
E
0

This is a strange issue, and is still alive and well in version 8.2.3 (build 8.2.3000.5176).

What seems to work for me on a consistent basis is to do a solution rebuild.

In VS 2013: Build -> Rebuild Solution

Envelope answered 30/12, 2014 at 21:50 Comment(0)
T
0

If the solutions above don't work you can try resetting the project output type. This seems to fix the issue on VS2015 Update 1 with ReSharper 10.1

Tetragrammaton answered 21/12, 2015 at 6:34 Comment(0)
M
0

For me none of the above worked. I had to install the new version of Resharper which supports NET Core 2.0.

Maynord answered 7/9, 2017 at 6:55 Comment(0)
V
0

Resharper was reporting a missing reference from a project that was included in the references. After trying the other solutions here, I disabled Resharper via the instructions this answer, and I found that Visual Studio's intellisense still reported the same errors.

At this point, I realized there was probably something wrong with the project file. I suspected a reference had gotten subtly corrupted during a merge.1

I deleted the reference it was complaining it couldn't find and re-added it. The errors from Visual Studio went away. Then I re-enabled Resharper, and it was no longer complaining about errors in my project.


  1. When I checked to see what had changed in the csproj file, what I found was an extra </Compile> that had no corresponding open tag. So it was indeed a merge error.
Venus answered 12/4, 2019 at 17:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.