Project Reference Problem, Visual Studio 2010

2019-04-03 10:31发布

I have a solution that has one class library project, and the others are WPF applications. I have added class library's reference the but, but both of them cannot use its classes.

So, what is the problem?

NOTE: sorry for tags, it's safari's problem.

4条回答
来,给爷笑一个
2楼-- · 2019-04-03 11:08

I got the same problem, but the solution was different...

We work in team and one of the developers (called dev1) installed the .NET 4.5 (the others has only the .NET 4.0). After dev1 made some changes in the solution the others got the problem, and colud't build. The project referrences didn't work (but if they used it like a dll it worked)... So we install the .NET 4.5 for everybody and it resolved the prolem.

Moha

查看更多
干净又极端
3楼-- · 2019-04-03 11:11

Found the problem. One of my references in class library has caused it, and I have removed it. Now I can built the solution without errors.

Thanks for your comments..

查看更多
何必那么认真
4楼-- · 2019-04-03 11:12

Things to check:

  • The class library classes are public
  • You have an appropriate using directive in your calling code:

    using MyCompany.ClassLibrary;
    

If that doesn't help, please post what happens when you try to use the classes from the library.

查看更多
够拽才男人
5楼-- · 2019-04-03 11:35

Make sure that all your projects target same Framework. It may be a case that your library class project targets full .Net Framework 4.0 while your wpf projects target .Net Framework 4.0 Client Profile.

To do that go to project properties of each project in a solution and check Application | Target Framework property. Alternatively you can download VSCommands 2010 extension and see all properties in one place via Solution Properties window.

查看更多
登录 后发表回答