Why can't I reference my class library?

后端 未结 20 1707
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 12:38

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

I then have another web site project outside of the solution that needs to refe

相关标签:
20条回答
  • 2020-12-08 13:20

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

    0 讨论(0)
  • 2020-12-08 13:25

    This sounds like a similar issue with ReSharper:

    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..

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

    0 讨论(0)
  • 2020-12-08 13:25

    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:

    • Drop reference to X from BOTH A and B
    • Recreate reference to X in B
    • Recreate reference to X in A

    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.

    0 讨论(0)
  • 2020-12-08 13:26

    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.

    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:

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

    0 讨论(0)
  • 2020-12-08 13:27

    You may forget 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)

    0 讨论(0)
  • 2020-12-08 13:28

    After confirming the same version of asp.net was being used. I removed the project. cleaned the solution and re-added the project. this is what worked for me.

    0 讨论(0)
提交回复
热议问题