简体   繁体   English

添加项目作为对另一个项目的引用

[英]Add project as reference to another project

I have two projects in the same solution. 我在同一个解决方案中有两个项目。 One is an ASP.NET MVC 2 Empty Web Application, the other is a Console Application. 一个是ASP.NET MVC 2空Web应用程序,另一个是控制台应用程序。

In the first project i create a database with EF and a class to access the database. 在第一个项目中,我使用EF创建一个数据库,并使用一个类来访问数据库。 What I want to do is add the first project as a reference to the console app project so i can use this class 我想要做的是添加第一个项目作为控制台应用程序项目的参考,所以我可以使用这个类

I included it as a reference already it appears at the References, and after is include a using directive at the top of my console app i can even use code assistance. 我将它作为参考包含在参考文献中,并且在我的控制台应用程序顶部包含一个using指令后,我甚至可以使用代码帮助。 But when i compile i always get the error: 但是当我编译时,我总是得到错误:

The type or namespace name 'DBModel' could not be found (are you missing a using directive or an assembly reference?) 找不到类型或命名空间名称“DBModel”(您是否缺少using指令或程序集引用?)

How can i compile my projects? 我怎样才能编译我的项目?

Sincerely, 此致

Zoli 佐利

From your description, if I'm getting it right, 根据你的描述,如果我做对了,

That's often the case when you have different target .NET framework (Project properties, Application, Target Framework) - ie one is eg .NET 4.0 Client Profile - and the lib you're referencing is just .NET 4.0. when you have different target .NET framework (项目属性,应用程序,目标框架) when you have different target .NET framework通常就是这种情况 - 例如,一个是.NET 4.0 Client Profile - 而您引用的lib只是.NET 4.0。

It's also possible that you're missing a reference to the Entity Framework in your Console application. 您也可能在控制台应用程序中缺少对实体框架的引用。

See this post for more info: http://www.dotnetcurry.com/ShowArticle.aspx?ID=617 (just below the middle, step 3). 有关详细信息,请参阅此文章: http//www.dotnetcurry.com/ShowArticle.aspx? ID = 617 (位于中间,第3步)。

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

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