简体   繁体   English

编译项目后,Visual Studio C#2010 Express引用无效

[英]Visual Studio C# 2010 Express references are invalid after compiling the project

I have two projekts in my c# solution explorer. 我的C#解决方案资源管理器中有两个项目。 The first project contains helper classes like a login to the database with NHibernate and some other stuff. 第一个项目包含帮助程序类,例如使用NHibernate和其他一些东西登录数据库。 My second project contains the main files for my programm like the GUI, their controllers etc. 我的第二个项目包含我程序的主要文件,例如GUI,其控制器等。

The second project references on the first project because I want to use functions of my helper classes in the second project. 第二个项目引用第一个项目,因为我想在第二个项目中使用助手类的功能。 I am able to compile the helper project with all its references (NHibernate.dll, Log4Net.dll etc.). 我能够使用其所有引用(NHibernate.dll,Log4Net.dll等)来编译帮助程序项目。

In the second project I face the following problem. 在第二个项目中,我面临以下问题。 There I also use some references that are already in the first project like the Log4Net.dll and of course I added a reference to my helper project because I want to use its functions. 在这里,我还使用了第一个项目中已经存在的一些引用,例如Log4Net.dll,当然,我添加了对助手项目的引用,因为我想使用其功能。 When I newly make all references everything is fine but when I compile the second project all references are away. 当我新创建所有引用时,一切都很好,但是当我编译第二个项目时,所有引用都消失了。 Better to say they are still in the reference folder but in the class files the references are red underlined and VS 2010 Express tells me that the types / namespaces could not be found (missing using directive or assembly reference). 最好说它们仍位于引用文件夹中,但在类文件中,引用用红色下划线标记,VS 2010 Express告诉我找不到类型/名称空间(缺少使用指令或程序集引用的名称)。

When I delete the references and make new references it works but again when I compile the project the same happens again. 当我删除引用并创建新引用时,它可以工作,但是当我编译项目时,同样会再次发生。

What am I doing wrong? 我究竟做错了什么?

First thing I'd scheck is the Target Farmework, are you perhaps targetting the first project to a higher version of the framework than the second project? 我首先要检查的是Target Farmework,也许您将第一个项目的目标定位为比第二个项目更高的框架版本? Then try setting the second project to the same target framework as the first one and see if that helps. 然后尝试将第二个项目设置为与第一个项目相同的目标框架,看看是否有帮助。

I think you first project is targeting the .net 4.0 (full) framework, and the second project is targeting the .net 4.0 client framework. 我认为您的第一个项目的目标是.net 4.0(完整)框架,第二个项目的目标是.net 4.0客户端框架。

Alter your second project so it also targets the .net 4.0 (full) framework. 更改您的第二个项目,使其也针对.net 4.0(完整)框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM