Why can't I reference my class library?

后端 未结 20 1704
隐瞒了意图╮
隐瞒了意图╮ 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:03

    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.

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

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

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

    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.

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

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

    If both projects are contained within the same solution, it will be more apropiate if you add the reference for the project you need, not its compiled dll.

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

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

    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.

    e.g.

    Class name: 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.

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

    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.

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

    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.

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