visual-studio 项目参考问题,Visual Studio 2010

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4313968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:49:30  来源:igfitidea点击:

Project Reference Problem, Visual Studio 2010

visual-studiovisual-studio-2010.net-4.0referenceproject-reference

提问by Kaan

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.

我有一个解决方案,它有一个类库项目,其他是 WPF 应用程序。我已经添加了类库的引用但是,但它们都不能使用它的类。

So, what is the problem?

那么,问题是什么?

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

注意:对于标签很抱歉,这是 safari 的问题。

采纳答案by Kaan

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

感谢您的意见..

回答by Registered User

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.

确保您的所有项目都针对相同的框架。可能是您的库类项目面向完整的 .Net Framework 4.0,而您的 wpf 项目面向 .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 2010extension and see all properties in one place via Solution Properties window.

为此,请转到解决方案中每个项目的项目属性并检查应用程序 | 目标框架属性。或者,您可以下载VSCommands 2010扩展并通过“解决方案属性”窗口在一处查看所有属性。

回答by Jon Skeet

Things to check:

检查事项:

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

    using MyCompany.ClassLibrary;
    
  • 类库类是公共的
  • using的调用代码中有一个适当的指令:

    using MyCompany.ClassLibrary;
    

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

如果这没有帮助,请发布当您尝试使用库中的类时会发生什么。

回答by Moha

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.

我们在团队中工作,其中一位开发人员(称为 dev1)安装了 .NET 4.5(其他人只有 .NET 4.0)。在 dev1 对解决方案进行了一些更改后,其他人遇到了问题,并且无法构建。项目引用不起作用(但如果他们像使用 dll 一样使用它,它就起作用了)......所以我们为每个人安装了 .NET 4.5,它解决了问题。

Moha

摩哈