[英]Assembly reference error on not used (and referenced) assembly, why do I this error?
In my solution I have three projects (Web, Business and Data) all are targeting .net 4.5.1. 在我的解决方案中,我有三个项目(Web,业务和数据)都针对.net 4.5.1。 Web references Business and Business references Data. Web参考业务和业务参考数据。
I need to execute a intitialization method in those three projects depending on the application start. 我需要根据应用程序启动在这三个项目中执行初始化方法。 So I have created a Boot class in all projects. 因此,我在所有项目中都创建了一个Boot类。
The Boot class in Business inherit from Boot class in Data and Boot class in Web inherite from Boot class in Business Business中的Boot类继承自Data中的Boot类,而Web中的Boot类继承于Business中的Boot类
So I have this code : 所以我有这段代码:
In Data project : 在数据项目中:
namespace Data
{
public class Boot
{
public Boot()
{
// init execution
}
}
}
In Business project : 在业务项目中:
namespace Business
{
public class Boot : Data.Boot
{
public Boot() : base()
{
// init execution
}
}
}
In Web project : 在Web项目中:
namespace Web
{
public class Boot : Business.Boot
{
public Boot() : base()
{
// init execution
}
}
}
And when I compile I have an error on my Boot class in Web project : 当我编译时,Web项目中的Boot类出现错误:
The type 'Data.Boot' is defined in an assembly that is not referenced. 类型“ Data.Boot”是在未引用的程序集中定义的。 You must add a reference to assembly 'Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 您必须添加对程序集'Data,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'的引用
And I don't understand why my Web project needs to references my Data project.. It never use Data.Boot directly.. 而且我不明白为什么我的Web项目需要引用我的Data项目。它从不直接使用Data.Boot。
You have to add a reference to your data project from within your web and business project. 您必须在Web和业务项目中添加对数据项目的引用。 In your case, your web layer is dependent on the business layer and data layer. 在您的情况下,您的Web层取决于业务层和数据层。
To summarize: 总结一下:
您必须检查在业务项目中是否引用了数据DLL,如果是,则必须清理解决方案并重新生成它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.