Project Reference Problem, Visual Studio 2010

假装没事ソ 提交于 2019-12-05 10:27:05

问题


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.


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/4313968/project-reference-problem-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!