ReSharper “Cannot resolve symbol” even when project builds

ぃ、小莉子 提交于 2019-11-26 02:39:43

问题


My Tools:

Visual Studio 2012 Ultimate + Update 1

ReSharper v7.1.25.234

My Solution Build Status: Build Successfully

But when I install ReSharper and ReSharper code analysis is enable, many keywords of my code are red with this error:

\"Cannot resolve symbol XXX\"

\"Enter


Another picture of my project >>

The ReSharper “CANNOT RESOLVE SYMBOL” errors are everywhere, but my project build process is successfully, and it works correctly.

\"Enter

Additional Note: If I disable ReSharper Code Analysis, my project will be Normal, but I want to use ReSharper code analysis.


I tried ReSharper → OptionsGeneralClear Cache. But I still have this problem!


  • One month ago, I got these errors when I uninstalled Visual Studio 2012 RC and installed VS 2012 RTM.

  • I\'ve already uninstalled and installed ReSharper again. But I have this problem yet!

  • My solution has five projects >> two loaded projects (main project + resource project) and three unloaded projects


I realize that my Visual Studio also has bigger problems (More information on Stack Overflow)

  • I can\'t add any reference to my projects (even inside new solutions and new projects)

  • I can\'t install any package (by \"Packet Manager Console\" or Manage NuGet Package)

  • I can\'t update any package (by \"Packet Manager Console\" or Manage NuGet Package)

I\'ve done a lot of suggestions (of myself and others)

  • Re-resister some DLL files

  • Using some windows and registry repair tools

  • Remove ReSharper

  • Repair Visual Studio

  • and...

But I could not solve it.

I\'m thinking of installing a new Windows :(


What is wrong, and how can I fix it?


回答1:


Try Visual Studio → menu ToolsOptionsReSharper, Suspend button and Resume again (no need to close the window). This works in my case.




回答2:


VS -> Tools -> Options -> ReSharper Suspend button 
Clear Contents of -> AppData\Local\JetBrains\ReSharper\v7.1\SolutionCaches
VS -> Tools -> Options -> ReSharper Resume  button



回答3:


This worked for me (VS2012u4, R# 7.1.3):

  1. Resharper > Options > Environment: General > Clear Caches
  2. Restart Visual Studio



回答4:


This happens in ReSharper when you have two different versions of the same library in your solution. For example project A references automapper version 1.1 and project B references automapper version 1.0.

Visual Studio will often compile and run as expected in the situation as it chooses one of the DLLs to bind to. However ReSharper gets massively confused. For me this should be a ReSharper error that it asks you to resolve rather than just going bonkers.

UPDATE:

I ran into this two days ago (a day after I made this post) by total coincidence and came across this link where they say that it is caused by a bug in the VS API. I tried everything that they recommended and was unable to resolve it even temporarily: I had Autofac 2.6.x that I'd downloaded from google.code and then swapped it over for the NuGet package version and it willfully refused to see the new reference no matter what I did.

They suggest installing the R# 8 EAP but for me it was less hassle to just downgrade to the old version of Autofac.

Not much in the way of help, but maybe useful.




回答5:


Clear Resharper cache: Resharper -> Options -> General -> Clear Caches, close and reopen the solution. It worked in R# 9.0 Update 1




回答6:


This was happening to me with Visual Studio 2015 and ReSharper Ultimate 10.0.2. I tried pretty much all the solutions above (apart from any reinstallations) and nothing worked.

I got it working again with a variety of the above steps in a very specific order:

  1. ReSharper → Options → Environment → General → Clear Caches
    • this must be done before suspending ReSharper as otherwise this option is unavailable
    • this clears out the files in C:\Users\YourUsername\AppData\Local\JetBrains\Transient\ReSharperPlatformVs14\v04 as mentioned in some other posts
  2. Tools → Options → ReSharper Ultimate → Suspend
  3. Close Visual Studio
    • this actually performs the ReSharper cache clear
  4. Open Visual Studio
  5. Open the solution
    • I waited for Visual Studio to detect there were no code issues in IntelliSense and may have performed a build at this point.
  6. Tools → Options → ReSharper Ultimate → Resume

Hopefully after the last step you can breathe a sigh of relief that you don't have to reinstall anything, I certainly did!




回答7:


It's usually happen by config file corrupt or wrong detect. Just delete .vs folder, restart VS to reset config. It will work almost case




回答8:


I had similar problems and cleared the caches found at:

AppData\Local\JetBrains\ReSharper\v7.1\SolutionCaches

Solved the problems for me

Running VS2012 u3




回答9:


Above links of clearing the cache and/or suspending the ReSharper did not work for me. I just 'refreshed' the project, which was showing this problem, from the solution explorer and the problem goes away. Sadly, it keeps on recurring and only option it to keep on refreshing every time this problem recurs.

I have VS2012 with ReSharper 8.1 on Windows 8




回答10:


I was just having the same issue with ReSharper 8.2 in Visual Studio 2013, and none of the usual solutions here of clearing caches, suspending ReSharper or re-installing ReSharper was working.

In my case I ended up solving it as follows... I looked at one of the symbols that it couldn't resolve and noted it was in System.Web.Http.dll. I then found that this was in the Microsoft.AspNet.WebApi.Core NuGet package. I used the package manager console to try and uninstall that package, except of course it told me that it couldn't due to other dependencies.

So I uninstalled each dependency up to and including Microsoft.AspNet.WebApi.Core, and then re-installed each package again in the reverse order. ReSharper picked everything up correctly as it was installed, and now seems fine.




回答11:


I had the same problem (VS 2017). In my case it was different versions of target framework - one assembly targeted 4.52, another 4.62 - after setting those to the same version in both assemblies it started working again.




回答12:


As you see the Solution is What everyone has already mentioned above. Simply by Suspending the Resharper then Clearing the Caches and finally Resuming it. But, no one mentioned how to do it Without closing/restarting VisualStudio.

Just Follow these Steps:

  1. Getting Resharper Cache Location

    • Manually by Going to Resharper Options > Environment > General > Store Solution Catches In(Combo Box)(Marked 2 in the Image). Selecting Custom Folder, Then Copying the location of the Catches Folder from the shown text box (Marked 3 in the Image). Reverting the settings back. The 1 Marked shows the ClearCache Button. It's Usually wouldn't work so leave it.
  2. Suspending Resharper
    • You can do this by going to Tools > Options > Resharper Or Resharper Ultimate > Suspend Now (Button)
  3. Clearing the Cache

    • Goto the location copied earlier in step 1 and delete every thing in that folder. And yes, I do mean everything.
  4. Resuming Resharper

    • You can do this by again going to Tools > Options > Resharper Or Resharper Ultimate > Resume (Button)



回答13:


I had the same issue and unloading and reloading problematic project helped me to clear out this issue for ReSharper. Hope this helps.




回答14:


I ended up needing to request Resharper to clear its cache along with doing it manually through Windows File Explorer. This finally resolved the issue for me.

  1. (As reported in many of the solutions here) RESHARPER > Options... > Environment > General > Clear Caches.
  2. Close Visual Studio.
  3. Go to this path in File Explorer for Resharper 10 in Visual Studio 2015: %localappdata%\JetBrains\Transient\ReSharperPlatformVs14
  4. Delete all subfolders and their contents within that folder.
  5. Restart Visual Studio, reload your Solution and wait for Resharper to initialize itself for the Solution.



回答15:


For me for VS2015, I had to update Resharper to version 2016.2.2 to resolve the issue.

I had already tried (of which none worked for me):

  • suspending / resuming
  • suspending / clearing cach (using tools > options button) / resuming
  • suspending / clearing cach (using Windows file system) / resuming
  • moving cache to solution folder / restarting visual studio
  • many other combinations of all or some of above

I hope that may help someone.




回答16:


Resharper -> Options Caches -> Store solution caches in: (Change folder to another one).

Or try to manually clean up R# cache folder




回答17:


I did everything above with no fix.

Then I did a step from another SO Q/A (don't remember which one) which was to set System.Web.Mvc to Copy Local true. Recompile my project and the errors went away.

When I set this assembly back to Copy Local false, the errors didn't return.




回答18:


I my case, I tried all the suggestions above. But, at some point I realized that the problem persists even if Resharper is suspended. So, I looked for similar problem in VS itself and found the solution in the comments for the accepted answer in this SO post.

I'm listing my steps for brevity.

  1. VS -> Tools -> Options -> ReSharper Suspend button
  2. Build solution. Notice all references still unresolved
  3. Clean the solution
  4. Restart VS
  5. Build the solution without Resharper. Notice all references resolved
  6. VS -> Tools -> Options -> ReSharper Resume button



回答19:


I'm using 7.1, and this worked for me:

  1. Uninstall resharper
  2. go to %appdata% and remove JetBrains\Resharper and ..\Local\JetBrains\Resharper folders
  3. re-install resharper



回答20:


I am using VS2015, R#10. None of the suggested solution worked for me. I deleted the contents of the bin folder of my solution and rebuild the entire solution, that seems to have resolved the issue. Before deleting the contents of the bin folder, I had tried suspending and resuming R#, doing clear cache from R# -> option -> general setting, and also manually deleting the contents from \AppData\Local\JetBrains\Transient\ReSharperPlatformVs12\v01\SolutionCaches.. Hope it helps someone.




回答21:


What helped in my case after several of the suggestions above didn't:

  • Removed one project reference (of one of the libraries where ReSharper claimed not to be able to find it even though it was correctly referenced).
  • Use ReSharper’s "Resolve" on one of its usages to add the reference again.

After that, it worked fine, even though none of the project files were actually modified in the process.




回答22:


I have the same problem.Clean Resharper cache and Suspend Resharper not worked for me.I just close visual studio, uninstall Resharper,and then install Resharper,the problem was gone.




回答23:


When I disabled ReSharper, Visual Studio was also giving the same error, even though the project built successfully. What I did to resolve the issue was:

  1. Remove the project from the solution.
  2. Right-click the solution, Add Existing Project, select the project file and add it again.

After performing these steps, the syntax errors went away in Visual Studio, and after I enabled ReSharper again, it also had no errors.




回答24:


For me, I think my solution just got caught in a weird state when I was changing which branch of my local Git repo I was on. Simply switching to the previous branch I was on before the problem started, telling VS to reload all the files, then switching back to the desired branch and reloading again fixed it.




回答25:


We saw this problem as well, specific to files which were shared by multiple projects. There is a combo box in the upper left corner of the editor window that lets you switch project context for the file (and hence the references that impact symbol resolution).

Resharper makes it easy to accidentally open the wrong "version" of a shared file by its "go to file or symbol" commands.

Switching context back to the project I use in the solution was all I needed to do to fix this issue.




回答26:


I also saw similar problems reported in ReSharper which did not lead to compile/runtime errors.

These were mostly seen when using "{x:Type ...}" or "{x:Static ...}" markup, causing ReSharper to report "Cannot resolve symbol 'Type'" or "Cannot resolve symbol 'Static'" errors.

Additionally there were many errors like "Invalid markup extension type: expected type is '<type>', actual type is '...Extension'".

The problem resolved itself when I added a reference to the System.Xaml assembly.




回答27:


No soft caches removal solutions worked for me, it looks like there were issues generated between different RS versions installed over the years.

What worked for me was:

  • Uninstal resharper
  • remove all JetBrains folders within AppData\Local and AppData\Roaming
  • Install resharper again

All the settings need to be redone, etc but I couldnt get any better solution even with help of JetBrains team.




回答28:


It should be a problem related to Resharper cache, but as far as I know, the "clear cache" feature works only if your cache is in Solution Folder. To check try this: Visual Studio > Tools > Options > Resharper > Options ...

In Resharper Options window > Environment > General check that "Store solution caches in" it's set to "Solution folder"

After this in solution folder you should see a new folder "_ReSharper.Caches". You should be able to clean it by pressing the "Clear caches" button, but (if this doesn't work) you can clean manually by removing inside files (in this case, Visual Studio has already to be closed).

Restart Visual Studio and everything should work. Have a look here [1] as well

[1] https://resharper-support.jetbrains.com/hc/en-us/articles/206546989-ReSharper-stopped-working-for-a-single-specific-solution

Note: Visual Studio 2015 Update 1 / ReSharper 10.0.2




回答29:


I was having the same issue in my Visual Studio 2015 with Resharper Ultimate and tried the solutions as suggested above, but none worked for me.

Then upgrading Resharper to latest release solved my issue.




回答30:


For me, inspecting the solution gave me hundreds of errors, including many "cannot find file in search paths". I tried every suggestion out there to fix it and none of them worked. I ended up finding out inspecting the project, instead of the solution, worked perfectly.



来源:https://stackoverflow.com/questions/15713167/resharper-cannot-resolve-symbol-even-when-project-builds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!