C# 即使在项目构建时,ReSharper“无法解析符号”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15713167/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ReSharper "Cannot resolve symbol" even when project builds
提问by RAM
My Tools:
我的工具:
Visual Studio 2012 Ultimate + Update 1
Visual Studio 2012 Ultimate + 更新 1
ReSharper v7.1.25.234
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:
但是当我安装 ReSharper 并启用 ReSharper 代码分析时,我的代码的许多关键字都是红色的,并出现此错误:
"Cannot resolve symbol XXX"
“无法解析符号 XXX”
Another picture of my project >>
我的项目的另一张照片>>
The ReSharper “CANNOT RESOLVE SYMBOL” errors are everywhere, but my project build process is successfully, and it works correctly.
ReSharper“无法解析符号”错误无处不在,但我的项目构建过程成功,并且工作正常。
Additional Note:If I disable ReSharper Code Analysis, my project will be Normal, but I want to use ReSharper code analysis.
附加说明:如果我禁用 ReSharper 代码分析,我的项目将是正常的,但我想使用 ReSharper 代码分析。
I triedReSharper → Options→ General→ Clear Cache. But I still have this problem!
我试过ReSharper → Options→ General→ Clear Cache。但是我还是有这个问题!
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
一个月前,我在卸载 Visual Studio 2012 RC 并安装 VS 2012 RTM 时遇到了这些错误。
我已经卸载并再次安装了 ReSharper。但是我还有这个问题!
我的解决方案有五个项目>>两个加载的项目(主项目+资源项目)和三个卸载的项目
I realize that my Visual Studio also has bigger problems(More information on Stack Overflow)
我意识到我的 Visual Studio 也有更大的问题(有关堆栈溢出的更多信息)
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)
我无法添加对我的项目的任何引用(即使在新解决方案和新项目中)
我无法安装任何包(通过“包管理器控制台”或管理 NuGet 包)
我无法更新任何包(通过“包管理器控制台”或管理 NuGet 包)
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...
重新抵抗一些 DLL 文件
使用一些 Windows 和注册表修复工具
删除 ReSharper
修复 Visual Studio
和...
But I could not solve it.
但我无法解决它。
I'm thinking of installing a new Windows:(
我正在考虑安装一个新的 Windows:(
What is wrong, and how can I fix it?
出了什么问题,我该如何解决?
采纳答案by RAM
I tested ALLof the other answers in this page (before writing this answer)such as:
我测试了此页面中的所有其他答案(在编写此答案之前),例如:
VS -> Tools -> Options -> ReSharper Suspendbutton and Resume
Clear ReSharper cache
And others
VS -> 工具 -> 选项 -> ReSharper暂停按钮和恢复
清除 ReSharper 缓存
和别的
But unfortunately none of them solved my problem. Maybe my problem was complicated than your problem. I said about them in my EDITsin the question, then the following answer was correct solution for mebut maybe other answers solve your problem. please test them first.
但不幸的是,他们都没有解决我的问题。也许我的问题比你的问题复杂。我在问题的编辑中谈到了它们,然后以下答案对我来说是正确的解决方案,但也许其他答案可以解决您的问题。请先测试它们。
I was forcedto reinstall my OS and use a newer version of my tools. :(
我被迫重新安装操作系统并使用更新版本的工具。:(
Now i use VS 2013 + R# v8 and when i have any problem with my resharper i just try the following instruction and it solve my problems:
现在我使用 VS 2013 + R# v8,当我的 resharper 有任何问题时,我只需尝试以下说明即可解决我的问题:
VS -> Tools -> Options -> ReSharper Suspend button and Resume
VS -> 工具 -> 选项 -> ReSharper 暂停按钮和恢复
回答by satnhak
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.
当您的解决方案中有同一个库的两个不同版本时,ReSharper 会发生这种情况。例如,项目 A 引用 automapper 版本 1.1,项目 B 引用 automapper 版本 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.
在这种情况下,Visual Studio 通常会按预期编译和运行,因为它会选择要绑定到的 DLL 之一。然而,ReSharper 变得非常困惑。对我来说,这应该是一个 ReSharper 错误,它要求您解决,而不仅仅是发疯。
UPDATE:
更新:
I ran into this two days ago (a day after I made this post) by total coincidence and came across this linkwhere 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.
两天前(在我发表这篇文章的第二天),我完全巧合地遇到了这个问题,并发现了这个链接,他们说这是由 VS API 中的错误引起的。我尝试了他们推荐的所有内容,但即使暂时也无法解决它:我从 google.code 下载了 Autofac 2.6.x,然后将其换成了 NuGet 包版本,但它故意拒绝查看新的参考编号不管我做了什么。
They suggest installing the R# 8 EAPbut for me it was less hassle to just downgrade to the old version of Autofac.
他们建议安装R# 8 EAP,但对我来说,降级到旧版本的 Autofac 没那么麻烦。
Not much in the way of help, but maybe useful.
没有多少帮助,但也许有用。
回答by Lu55
Try Visual Studio → menu Tools→ Options→ ReSharper, Suspendbutton and Resumeagain (no need to close the window). This works in my case.
再次尝试 Visual Studio → 菜单工具→选项→ ReSharper,Suspend按钮并Resume再次尝试(无需关闭窗口)。这在我的情况下有效。
回答by HotN
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.
对我来说,我认为我的解决方案只是在我更改我所在的本地 Git 存储库的哪个分支时陷入了一种奇怪的状态。只需切换到问题开始之前我所在的上一个分支,告诉 VS 重新加载所有文件,然后切换回所需的分支并再次重新加载即可修复它。
回答by nils
I had similar problems and cleared the caches found at:
我遇到了类似的问题并清除了在以下位置找到的缓存:
AppData\Local\JetBrains\ReSharper\v7.1\SolutionCaches
AppData\Local\JetBrains\ReSharper\v7.1\SolutionCaches
Solved the problems for me
为我解决了问题
Running VS2012 u3
运行 VS2012 u3
回答by ragnar
I'm using 7.1, and this worked for me:
我正在使用 7.1,这对我有用:
- Uninstall resharper
- go to %appdata% and remove JetBrains\Resharper and ..\Local\JetBrains\Resharper folders
- re-install resharper
- 卸载 resharper
- 转到 %appdata% 并删除 JetBrains\Resharper 和 ..\Local\JetBrains\Resharper 文件夹
- 重新安装resharper
回答by Marcel
VS -> Tools -> Options -> ReSharper Suspend button
Clear Contents of -> AppData\Local\JetBrains\ReSharper\v7.1\SolutionCaches
VS -> Tools -> Options -> ReSharper Resume button
回答by Jeroen K
This worked for me (VS2012u4, R# 7.1.3):
这对我有用(VS2012u4,R# 7.1.3):
- Resharper > Options > Environment: General > Clear Caches
- Restart Visual Studio
- Resharper > 选项 > 环境:常规 > 清除缓存
- 重新启动 Visual Studio
回答by Teoman shipahi
I had the same issue and unloading and reloading problematic project helped me to clear out this issue for ReSharper. Hope this helps.
我遇到了同样的问题,卸载和重新加载有问题的项目帮助我为 ReSharper 解决了这个问题。希望这可以帮助。
回答by sppc42
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.
以上清除缓存和/或暂停 ReSharper 的链接对我不起作用。我只是从解决方案资源管理器中“刷新”了显示此问题的项目,问题就消失了。可悲的是,它会不断重复出现,并且只能选择在每次此问题再次出现时继续刷新。
I have VS2012 with ReSharper 8.1 on Windows 8
我在 Windows 8 上安装了带有 ReSharper 8.1 的 VS2012
回答by James Thurley
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.
我只是在 Visual Studio 2013 中遇到了与 ReSharper 8.2 相同的问题,这里清除缓存、暂停 ReSharper 或重新安装 ReSharper 的常用解决方案都不起作用。
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.
在我的情况下,我最终按如下方式解决它......我查看了它无法解决的符号之一并注意到它在System.Web.Http.dll
. 然后我发现这是在Microsoft.AspNet.WebApi.Core
NuGet 包中。我使用包管理器控制台尝试卸载该包,当然它告诉我由于其他依赖项而无法卸载。
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.
所以我卸载了每个依赖项,包括Microsoft.AspNet.WebApi.Core
,然后以相反的顺序再次重新安装每个包。ReSharper 在安装时正确拾取了所有内容,现在看起来不错。