为什么我不能引用我的类库?

时间:2022-04-18 21:07:48

I have a solution that contains a website and a class library in Visual Studio 2008.

我有一个解决方案,在Visual Studio 2008中包含一个网站和一个类库。

I then have another web site project outside of the solution that needs to reference the class library. I right click the Bin folder or Project and select Add Reference, then select my Class Library Project, it adds the 15 or so DLLs that the class library needs to the websites bin folder, but none of the .cs files recognize the using statements.

然后,我在解决方案之外还有另一个web站点项目需要引用类库。我右键单击Bin文件夹或项目,选择Add Reference,然后选择我的类库项目,它将类库需要的大约15个dll添加到website Bin文件夹,但没有一个.cs文件能识别using语句。

using MyLibrary.MyFolder;

It says that it can't resolve it, and ReSharper just says it can be safely removed since it's not being used.

它说它不能解决它,ReSharper只是说它可以安全地移除因为它没有被使用。

ReSharper can recognize that it needs the reference and suggests that it "Reference MyLibrary and use MyFolder". I'm not sure why it's suggesting I add a reference I already have. When I go with the suggestion, I get the error

ReSharper可以识别它需要引用并且建议它“引用MyLibrary和使用MyFolder”。我不知道为什么它建议我添加一个我已经有过的引用。当我按照这个建议去做时,我得到了错误

"Failed to reference module. Probably, reference will produce circular dependencies between projects."

“未能引用模块。可能,引用会在项目之间产生循环依赖。

I've tried going to the websites property pages and removing all the references and re-adding them, but it gives the same errors. Any ideas why this isn't working?

我已经试过访问网站属性页面并删除所有引用并重新添加它们,但它也会产生相同的错误。有什么不明白的吗?

18 个解决方案

#1


134  

Also, check that the new solution's projects run against a compatible framework to the project you're trying to include. I was trying to include a reference to a 4.0 project in a 3.5 project.

另外,检查新解决方案的项目是否运行在与要包含的项目兼容的框架上。我试图在3.5项目中包含一个4.0的参考。

#2


78  

I found how to fix this issue (for me at least). Why it worked, I'm not sure, but it did. (I just tried against a second website that was having the same problem and the following solution worked for that as well).

我找到了解决这个问题的方法(至少对我来说)。我不确定它为什么有效,但它确实有效。(我刚刚尝试了另一个有同样问题的网站,下面的解决方案也适用于这个网站)。

I tried the normal cleaning of the projects and rebuilding, shutting down all my Visual Studio instances and restarting them, even tried restarting my computer.

我尝试了正常的项目清理和重建,关闭了所有的Visual Studio实例并重新启动它们,甚至尝试了重新启动我的计算机。

What actually worked was opening up the project in Visual Studio, closing all the open tabs, and then shutting it down.

真正起作用的是在Visual Studio中打开项目,关闭所有打开的选项卡,然后关闭它。

Before I had left the tabs open because I didn't think it mattered (and I hardly ever close the tabs I'm using).

在我打开标签之前,因为我不认为这很重要(而且我几乎从不关闭我正在使用的标签)。

#3


30  

One possibility is that the target .NET Framework version of the class library is higher than that of the project.

一种可能是类库的目标。net框架版本比项目版本高。

#4


8  

I had a similar problem, will all my references being buggered up by Resharper - The solution which worked for me is to clear the Resharper Cache and then restarting VS

我也遇到过类似的问题,Resharper对我所有的引用都会被拦截吗?我的解决方案是清除Resharper缓存,然后重新开始VS

tools->options->resharper->options-> general-> click the clear caches button and restart VS

工具->选项->resharper->选项->通用->点击清除缓存按钮重新启动VS

#5


4  

I had a similar problems where VS would sometimes build and sometimes not. After some searching and attempts I discovered that I had an ambiguous reference to a class with the same name in different libraries ('FileManager'). The project that would not build were my Unit Tests that reference all modules in my solution. Enforcing the reference to a specific module sorted things out for me.

我也遇到过类似的问题,而VS有时会生成,有时不会。经过一些搜索和尝试之后,我发现我对不同库中同名的类(“FileManager”)有一个不明确的引用。不构建的项目是我的单元测试,它引用了我的解决方案中的所有模块。对特定模块执行引用为我整理了一些东西。

My point is: Rather than blaming ReSharper or VS, it may be a good idea to double check if there really isn't some kind of circular reference somehow. More than often, classes with the same names in different modules could cause confusion and is often a symptom of bad design (like in my case).

我的观点是:与其责怪ReSharper或VS,不如仔细检查一下是否真的没有某种循环引用。通常,不同模块中具有相同名称的类会引起混乱,并且常常是糟糕设计的一个症状(就像我的例子)。

#6


3  

This sounds like a similar issue with ReSharper:

这听起来和ReSharper相似:

http://www.jetbrains.net/devnet/thread/275827

http://www.jetbrains.net/devnet/thread/275827

According to one user in the thread forcing a build fixes the issue (CTRL+Shift+B) after the first build..

根据线程中的一个用户强制构建在第一次构建之后修复问题(CTRL+Shift+B)。

Sounds like an issue with ReSharper specifically in their case.. Have you tried building regardless of the warnings and possible false errors?

就他们的情况而言,这听起来像是一个更尖锐的问题。您是否尝试过不顾警告和可能的错误进行构建?

#7


2  

Since they are both in the same solution, instead of adding a reference to the DLL, add a reference to the class library project itself (the Add Reference dialog will have a tab for this).

由于它们都在同一个解决方案中,所以不向DLL添加引用,而是向类库项目本身添加引用(添加引用对话框将为此提供一个选项卡)。

Ahh, it's a different solution. Missed that. How about you try instead of adding a reference to the project addding a reference to the compiled DLL of your class library. The Add Reference dialog has a Browse tab which does this.

啊,这是一个不同的解。错过了。不如试试,不要添加对项目的引用,添加对类库编译DLL的引用。添加引用对话框有一个浏览选项卡。

#8


2  

If you're referencing assemblies for projects that are in the same solution, add a Project reference (using the "Projects" tab) rather than browsing for the dll in the \bin\Debug (or \bin\Release) folder (using the "Browse" tab). See screen shot below. Only browse for the assembly/dll file if it's considered an external assembly.

如果您正在为同一解决方案中的项目引用程序集,请添加一个项目引用(使用“projects”选项卡),而不是使用“Browse”选项卡(使用“Browse”选项卡)在\bin\ bin Debug(或\bin\ bin\Release)文件夹中浏览dll。请参阅下面的屏幕截图。只浏览程序集/dll文件,如果它被认为是外部程序集。

为什么我不能引用我的类库?

#9


2  

I deleted *.csproj.user ( resharper file) of my project, then, close all tabs and reopen it. After that I was able to compile my project and there was no resharper warnings.

我* .csproj删除。我的项目的用户(resharper file),然后关闭所有的标签并重新打开它。之后我就可以编译我的项目了,并且没有resharper警告。

#10


2  

I had this problem. It took me ages to figure out. I had people over my shoulder to help. We rebuilt, cleaned and restarted Visual studio and this didn't fix it. We removed and re-added the references...

我有这个问题。我花了很长时间才弄明白。我的肩膀上有人帮忙。我们重新构建、清理和重新启动了Visual studio,但这并没有修复它。我们删除并重新添加了引用…

All to no avail.... Until!

但这一切都无济于事....直到!

The solution to my problem was that my class declaration was spelt incorrectly.

我的问题的解决方案是我的类声明拼写错误。

Before you start judging me harshly, allow me to explain why it wasn't stupid, and also why this mistake could be made by even the most intelligent of programmers.

在你开始严厉地批评我之前,请允许我解释为什么它不愚蠢,以及为什么即使是最聪明的程序员也会犯这种错误。

Since the mistake was early on in the name, it wasn't appearing in the intellisense class listing when I began typing.

由于错误出现在名称的早期,所以当我开始输入时,它并没有出现在intellisense类列表中。

e.g.

如。

Class name: Message.cs

类名:Message.cs

Declaration:

声明:

public class Massage
{
    //code here

}

At a glance and in a small font, Massage looks identical to Message.

看一眼,用一个小字体,按摩看起来和信息是一样的。

Typing M listed too many classes, so I typed e, which didn't appear in the mistyped version, which gave the impression that the class wasn't being picked up by the compiler.

输入M列出了太多的类,所以我输入了e,它没有出现在输入错误的版本中,这给人的印象是这个类没有被编译器选中。

#11


0  

I had a similar issue in VS 2010, when creating a test project for an MVC 2 application. The symptoms were identical.

在VS 2010中,我遇到了类似的问题,当时我为一个MVC 2应用程序创建了一个测试项目。症状是相同的。

The message from ReSharper was somewhat misleading. For a moment I completely ignored ReSharper and did it the "manual VS way":

来自ReSharper的信息有点误导人。有一段时间,我完全忽略了ReSharper,用“manual VS way”做了这件事:

  1. I cleaned the solution.
  2. 我打扫的解决方案。
  3. I manually added the reference to the MVC project.
  4. 我手动添加了对MVC项目的引用。
  5. I manually added the using directives.
  6. 我手动添加了使用指令。
  7. ctrl-shift-b
  8. ctrl-shift-b

At this stage I got a compilation error: I should have referenced the System.Web.Mvc assembly in my test project (sigh). Adding this reference causes the project to compile. The ReSharper issues remain, but the ReSharper test runner works.

在这个阶段,我得到了一个编译错误:我应该引用System.Web。在我的测试项目中(叹气)。添加此引用将导致项目编译。更尖锐的问题仍然存在,但更尖锐的测试跑者起作用。

When I restart VS, the ReSharper errors are gone too. I'm not sure if the restart is required - simply closing the .cs file might be enough.

当我重新启动VS时,ReSharper错误也会消失。我不确定是否需要重新启动——仅仅关闭.cs文件就足够了。

From now on, when I see the ReSharper message

从现在开始,当我看到更清晰的信息

Failed to reference module. Probably, reference will produce circular dependencies between projects.

没有参考模块。可能,引用会在项目之间产生循环依赖。

I'll read

我来读

Failed to reference module. Probably, reference will produce circular dependencies between projects, or you are missing some references to dependencies of the reference's dependencies.

没有参考模块。可能,引用会在项目之间产生循环依赖,或者您正在丢失对引用依赖项的引用。

#12


0  

Another possible fix that just worked for me:

另一个可能的解决方法是:

If you have Assembly A, which references Assembly B, both of which reference a non-project (external) assembly X, and Assembly B's code will not recognize that you have referenced X, then try the following steps in order:

如果你有一个汇编A,它引用了汇编B,这两个都引用了一个非项目(外部)程序集X,而汇编B的代码不认识到你引用了X,那么按以下步骤依次进行:

  • Drop reference to X from BOTH A and B
  • 从A和B中删除对X的引用
  • Recreate reference to X in B
  • 在B中重新创建对X的引用
  • Recreate reference to X in A
  • 在A中重新创建对X的引用

Apparently, VS will not recognize a reference to an external assembly in a project that is a dependency of another project that already references the external. By setting up the references again from the ground up, you overcome this. It's just very odd.

显然,VS不会识别一个项目中对外部程序集的引用,而这个项目依赖于已经引用外部的另一个项目。通过从头开始重新设置引用,您就克服了这个问题。这只是非常奇怪。

#13


0  

If using TFS, performing a Get latest (recursive) doesn't always work. Instead, I force a get latest by clicking Source control => Get specific version then clicking both boxes. This tends to work.

如果使用TFS,执行Get latest(递归)并不总是有效的。相反,我通过单击Source control =>获取特定版本来强制获取最新版本,然后单击这两个框。这往往工作。

为什么我不能引用我的类库?

If it still doesn't work then deleting the suo file (usually found in the same place as the solution) forces visual studio to get all the files from the source (and subsequently rebuild the suo file).

如果它仍然不起作用,那么删除suo文件(通常与解决方案位于同一位置)将迫使visual studio从源获取所有文件(然后重新构建suo文件)。

If that doesn't work then try closing all your open files and closing Visual studio. When you next open Visual studio it should be fixed. There is a resharper bug that is resolved this way.

如果这不起作用,那么尝试关闭所有打开的文件并关闭Visual studio。当您下一次打开Visual studio时,它应该被修复。有一个resharper错误以这种方式解析。

#14


0  

I had stumbled upon a similar issue recently. I am working in Visual Studio 2015 with Resharper Ultimate 2016.1.2. I was trying to add a new class to my code base while trying to reference a class from another assembly but Resharper would throw an error for that package.

我最近遇到了一个类似的问题。我在Visual Studio 2015工作,Resharper Ultimate 2016.1.2。我试图在代码库中添加一个新类,同时尝试从另一个程序集引用一个类,但是Resharper会为这个包抛出一个错误。

With some help of a co-worker, I figured out that the referenced class existed in the global namespace and wasn't accessible from the new class since it was hidden by another entity of same name that existed in current namespace.

在一位同事的帮助下,我发现引用的类存在于全局名称空间中,并且不能从新类中访问,因为它被当前名称空间中存在的另一个同名实体隐藏。

Adding a 'global::' keyword before the required namespace helped me to reference the class I was actually looking for. More details on this can be found on the page listed below:

在所需的名称空间之前添加一个“global::”关键字,可以帮助我引用我实际上正在查找的类。有关详情,请参阅以下网页:

https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

#15


-1  

I faced this problem, and I solved it by closing visual studio, reopening visual studio, cleaning and rebuilding the solution. This worked for me.

我遇到了这个问题,我通过关闭visual studio、重新打开visual studio、清理和重新构建解决方案来解决它。这为我工作。

#16


-1  

Unfortunately the only thing that worked for me was completely deleting and recreating the class library project, after having temporarily copied the class files in it elsewhere. Only then would the ASP.Net web project recognise the using statements that referred to the class library project. This was with Visual Studio 2010, not using ReSharper.

不幸的是,在临时将类文件复制到其他地方之后,唯一对我有用的是完全删除和重新创建类库项目。只有这样,ASP才会出现。Net web项目识别引用类库项目的使用语句。这是使用Visual Studio 2010,而不是使用ReSharper。

#17


-1  

I had similar issue. What worked for me is that I had added wrong Class Library from visual studio. I added by using the search feature of visual studio.

我也有类似的问题。对我有用的是我在visual studio中添加了错误的类库。我添加了visual studio的搜索功能。

What I needed to do was Add New Project > Visual C# > Class Library. And this newly added class library is the right one and can now be added as reference to any project.

我需要做的是添加新的Project > Visual c# >类库。这个新添加的类库是正确的,现在可以作为任何项目的参考添加。

#18


-2  

You may forgot to add reference the class library which you needed to import.

您可能忘记添加要导入的类库的引用。

Right click the class library which you want to import in (which contains multiple imported class libraries), -->Add->Reference(Select Projects->Solution->select the class library which you want to import from->OK)

右键单击要导入的类库(其中包含多个导入的类库),>添加->引用(选择项目->解决方案->选择要从->导入的类库)

#1


134  

Also, check that the new solution's projects run against a compatible framework to the project you're trying to include. I was trying to include a reference to a 4.0 project in a 3.5 project.

另外,检查新解决方案的项目是否运行在与要包含的项目兼容的框架上。我试图在3.5项目中包含一个4.0的参考。

#2


78  

I found how to fix this issue (for me at least). Why it worked, I'm not sure, but it did. (I just tried against a second website that was having the same problem and the following solution worked for that as well).

我找到了解决这个问题的方法(至少对我来说)。我不确定它为什么有效,但它确实有效。(我刚刚尝试了另一个有同样问题的网站,下面的解决方案也适用于这个网站)。

I tried the normal cleaning of the projects and rebuilding, shutting down all my Visual Studio instances and restarting them, even tried restarting my computer.

我尝试了正常的项目清理和重建,关闭了所有的Visual Studio实例并重新启动它们,甚至尝试了重新启动我的计算机。

What actually worked was opening up the project in Visual Studio, closing all the open tabs, and then shutting it down.

真正起作用的是在Visual Studio中打开项目,关闭所有打开的选项卡,然后关闭它。

Before I had left the tabs open because I didn't think it mattered (and I hardly ever close the tabs I'm using).

在我打开标签之前,因为我不认为这很重要(而且我几乎从不关闭我正在使用的标签)。

#3


30  

One possibility is that the target .NET Framework version of the class library is higher than that of the project.

一种可能是类库的目标。net框架版本比项目版本高。

#4


8  

I had a similar problem, will all my references being buggered up by Resharper - The solution which worked for me is to clear the Resharper Cache and then restarting VS

我也遇到过类似的问题,Resharper对我所有的引用都会被拦截吗?我的解决方案是清除Resharper缓存,然后重新开始VS

tools->options->resharper->options-> general-> click the clear caches button and restart VS

工具->选项->resharper->选项->通用->点击清除缓存按钮重新启动VS

#5


4  

I had a similar problems where VS would sometimes build and sometimes not. After some searching and attempts I discovered that I had an ambiguous reference to a class with the same name in different libraries ('FileManager'). The project that would not build were my Unit Tests that reference all modules in my solution. Enforcing the reference to a specific module sorted things out for me.

我也遇到过类似的问题,而VS有时会生成,有时不会。经过一些搜索和尝试之后,我发现我对不同库中同名的类(“FileManager”)有一个不明确的引用。不构建的项目是我的单元测试,它引用了我的解决方案中的所有模块。对特定模块执行引用为我整理了一些东西。

My point is: Rather than blaming ReSharper or VS, it may be a good idea to double check if there really isn't some kind of circular reference somehow. More than often, classes with the same names in different modules could cause confusion and is often a symptom of bad design (like in my case).

我的观点是:与其责怪ReSharper或VS,不如仔细检查一下是否真的没有某种循环引用。通常,不同模块中具有相同名称的类会引起混乱,并且常常是糟糕设计的一个症状(就像我的例子)。

#6


3  

This sounds like a similar issue with ReSharper:

这听起来和ReSharper相似:

http://www.jetbrains.net/devnet/thread/275827

http://www.jetbrains.net/devnet/thread/275827

According to one user in the thread forcing a build fixes the issue (CTRL+Shift+B) after the first build..

根据线程中的一个用户强制构建在第一次构建之后修复问题(CTRL+Shift+B)。

Sounds like an issue with ReSharper specifically in their case.. Have you tried building regardless of the warnings and possible false errors?

就他们的情况而言,这听起来像是一个更尖锐的问题。您是否尝试过不顾警告和可能的错误进行构建?

#7


2  

Since they are both in the same solution, instead of adding a reference to the DLL, add a reference to the class library project itself (the Add Reference dialog will have a tab for this).

由于它们都在同一个解决方案中,所以不向DLL添加引用,而是向类库项目本身添加引用(添加引用对话框将为此提供一个选项卡)。

Ahh, it's a different solution. Missed that. How about you try instead of adding a reference to the project addding a reference to the compiled DLL of your class library. The Add Reference dialog has a Browse tab which does this.

啊,这是一个不同的解。错过了。不如试试,不要添加对项目的引用,添加对类库编译DLL的引用。添加引用对话框有一个浏览选项卡。

#8


2  

If you're referencing assemblies for projects that are in the same solution, add a Project reference (using the "Projects" tab) rather than browsing for the dll in the \bin\Debug (or \bin\Release) folder (using the "Browse" tab). See screen shot below. Only browse for the assembly/dll file if it's considered an external assembly.

如果您正在为同一解决方案中的项目引用程序集,请添加一个项目引用(使用“projects”选项卡),而不是使用“Browse”选项卡(使用“Browse”选项卡)在\bin\ bin Debug(或\bin\ bin\Release)文件夹中浏览dll。请参阅下面的屏幕截图。只浏览程序集/dll文件,如果它被认为是外部程序集。

为什么我不能引用我的类库?

#9


2  

I deleted *.csproj.user ( resharper file) of my project, then, close all tabs and reopen it. After that I was able to compile my project and there was no resharper warnings.

我* .csproj删除。我的项目的用户(resharper file),然后关闭所有的标签并重新打开它。之后我就可以编译我的项目了,并且没有resharper警告。

#10


2  

I had this problem. It took me ages to figure out. I had people over my shoulder to help. We rebuilt, cleaned and restarted Visual studio and this didn't fix it. We removed and re-added the references...

我有这个问题。我花了很长时间才弄明白。我的肩膀上有人帮忙。我们重新构建、清理和重新启动了Visual studio,但这并没有修复它。我们删除并重新添加了引用…

All to no avail.... Until!

但这一切都无济于事....直到!

The solution to my problem was that my class declaration was spelt incorrectly.

我的问题的解决方案是我的类声明拼写错误。

Before you start judging me harshly, allow me to explain why it wasn't stupid, and also why this mistake could be made by even the most intelligent of programmers.

在你开始严厉地批评我之前,请允许我解释为什么它不愚蠢,以及为什么即使是最聪明的程序员也会犯这种错误。

Since the mistake was early on in the name, it wasn't appearing in the intellisense class listing when I began typing.

由于错误出现在名称的早期,所以当我开始输入时,它并没有出现在intellisense类列表中。

e.g.

如。

Class name: Message.cs

类名:Message.cs

Declaration:

声明:

public class Massage
{
    //code here

}

At a glance and in a small font, Massage looks identical to Message.

看一眼,用一个小字体,按摩看起来和信息是一样的。

Typing M listed too many classes, so I typed e, which didn't appear in the mistyped version, which gave the impression that the class wasn't being picked up by the compiler.

输入M列出了太多的类,所以我输入了e,它没有出现在输入错误的版本中,这给人的印象是这个类没有被编译器选中。

#11


0  

I had a similar issue in VS 2010, when creating a test project for an MVC 2 application. The symptoms were identical.

在VS 2010中,我遇到了类似的问题,当时我为一个MVC 2应用程序创建了一个测试项目。症状是相同的。

The message from ReSharper was somewhat misleading. For a moment I completely ignored ReSharper and did it the "manual VS way":

来自ReSharper的信息有点误导人。有一段时间,我完全忽略了ReSharper,用“manual VS way”做了这件事:

  1. I cleaned the solution.
  2. 我打扫的解决方案。
  3. I manually added the reference to the MVC project.
  4. 我手动添加了对MVC项目的引用。
  5. I manually added the using directives.
  6. 我手动添加了使用指令。
  7. ctrl-shift-b
  8. ctrl-shift-b

At this stage I got a compilation error: I should have referenced the System.Web.Mvc assembly in my test project (sigh). Adding this reference causes the project to compile. The ReSharper issues remain, but the ReSharper test runner works.

在这个阶段,我得到了一个编译错误:我应该引用System.Web。在我的测试项目中(叹气)。添加此引用将导致项目编译。更尖锐的问题仍然存在,但更尖锐的测试跑者起作用。

When I restart VS, the ReSharper errors are gone too. I'm not sure if the restart is required - simply closing the .cs file might be enough.

当我重新启动VS时,ReSharper错误也会消失。我不确定是否需要重新启动——仅仅关闭.cs文件就足够了。

From now on, when I see the ReSharper message

从现在开始,当我看到更清晰的信息

Failed to reference module. Probably, reference will produce circular dependencies between projects.

没有参考模块。可能,引用会在项目之间产生循环依赖。

I'll read

我来读

Failed to reference module. Probably, reference will produce circular dependencies between projects, or you are missing some references to dependencies of the reference's dependencies.

没有参考模块。可能,引用会在项目之间产生循环依赖,或者您正在丢失对引用依赖项的引用。

#12


0  

Another possible fix that just worked for me:

另一个可能的解决方法是:

If you have Assembly A, which references Assembly B, both of which reference a non-project (external) assembly X, and Assembly B's code will not recognize that you have referenced X, then try the following steps in order:

如果你有一个汇编A,它引用了汇编B,这两个都引用了一个非项目(外部)程序集X,而汇编B的代码不认识到你引用了X,那么按以下步骤依次进行:

  • Drop reference to X from BOTH A and B
  • 从A和B中删除对X的引用
  • Recreate reference to X in B
  • 在B中重新创建对X的引用
  • Recreate reference to X in A
  • 在A中重新创建对X的引用

Apparently, VS will not recognize a reference to an external assembly in a project that is a dependency of another project that already references the external. By setting up the references again from the ground up, you overcome this. It's just very odd.

显然,VS不会识别一个项目中对外部程序集的引用,而这个项目依赖于已经引用外部的另一个项目。通过从头开始重新设置引用,您就克服了这个问题。这只是非常奇怪。

#13


0  

If using TFS, performing a Get latest (recursive) doesn't always work. Instead, I force a get latest by clicking Source control => Get specific version then clicking both boxes. This tends to work.

如果使用TFS,执行Get latest(递归)并不总是有效的。相反,我通过单击Source control =>获取特定版本来强制获取最新版本,然后单击这两个框。这往往工作。

为什么我不能引用我的类库?

If it still doesn't work then deleting the suo file (usually found in the same place as the solution) forces visual studio to get all the files from the source (and subsequently rebuild the suo file).

如果它仍然不起作用,那么删除suo文件(通常与解决方案位于同一位置)将迫使visual studio从源获取所有文件(然后重新构建suo文件)。

If that doesn't work then try closing all your open files and closing Visual studio. When you next open Visual studio it should be fixed. There is a resharper bug that is resolved this way.

如果这不起作用,那么尝试关闭所有打开的文件并关闭Visual studio。当您下一次打开Visual studio时,它应该被修复。有一个resharper错误以这种方式解析。

#14


0  

I had stumbled upon a similar issue recently. I am working in Visual Studio 2015 with Resharper Ultimate 2016.1.2. I was trying to add a new class to my code base while trying to reference a class from another assembly but Resharper would throw an error for that package.

我最近遇到了一个类似的问题。我在Visual Studio 2015工作,Resharper Ultimate 2016.1.2。我试图在代码库中添加一个新类,同时尝试从另一个程序集引用一个类,但是Resharper会为这个包抛出一个错误。

With some help of a co-worker, I figured out that the referenced class existed in the global namespace and wasn't accessible from the new class since it was hidden by another entity of same name that existed in current namespace.

在一位同事的帮助下,我发现引用的类存在于全局名称空间中,并且不能从新类中访问,因为它被当前名称空间中存在的另一个同名实体隐藏。

Adding a 'global::' keyword before the required namespace helped me to reference the class I was actually looking for. More details on this can be found on the page listed below:

在所需的名称空间之前添加一个“global::”关键字,可以帮助我引用我实际上正在查找的类。有关详情,请参阅以下网页:

https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

#15


-1  

I faced this problem, and I solved it by closing visual studio, reopening visual studio, cleaning and rebuilding the solution. This worked for me.

我遇到了这个问题,我通过关闭visual studio、重新打开visual studio、清理和重新构建解决方案来解决它。这为我工作。

#16


-1  

Unfortunately the only thing that worked for me was completely deleting and recreating the class library project, after having temporarily copied the class files in it elsewhere. Only then would the ASP.Net web project recognise the using statements that referred to the class library project. This was with Visual Studio 2010, not using ReSharper.

不幸的是,在临时将类文件复制到其他地方之后,唯一对我有用的是完全删除和重新创建类库项目。只有这样,ASP才会出现。Net web项目识别引用类库项目的使用语句。这是使用Visual Studio 2010,而不是使用ReSharper。

#17


-1  

I had similar issue. What worked for me is that I had added wrong Class Library from visual studio. I added by using the search feature of visual studio.

我也有类似的问题。对我有用的是我在visual studio中添加了错误的类库。我添加了visual studio的搜索功能。

What I needed to do was Add New Project > Visual C# > Class Library. And this newly added class library is the right one and can now be added as reference to any project.

我需要做的是添加新的Project > Visual c# >类库。这个新添加的类库是正确的,现在可以作为任何项目的参考添加。

#18


-2  

You may forgot to add reference the class library which you needed to import.

您可能忘记添加要导入的类库的引用。

Right click the class library which you want to import in (which contains multiple imported class libraries), -->Add->Reference(Select Projects->Solution->select the class library which you want to import from->OK)

右键单击要导入的类库(其中包含多个导入的类库),>添加->引用(选择项目->解决方案->选择要从->导入的类库)