简体   繁体   English

未使用(和引用)的程序集上的程序集引用错误,为什么会出现此错误?

[英]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: 总结一下:

  • Web project references business project and data project Web项目引用业务项目和数据项目
  • business references data project 业务参考数据项目

您必须检查在业务项目中是否引用了数据DLL,如果是,则必须清理解决方案并重新生成它

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

相关问题 引用的程序集引用错误 - referenced assembly reference error WatiN引用的组装错误 - WatiN referenced assembly error 为什么我(有时)必须引用我引用的程序集引用的程序集? - Why do I (sometimes) have to reference assemblies referenced by the assembly I reference? Windows Service中的程序集未引用错误 - Assembly not referenced error in Windows Service SSRS组装参考错误 - SSRS assembly reference error 组装参考错误 - Assembly reference error 参考装配错误 - Reference to assembly error 为什么我得到:“IThirdParty”类型是在未引用的程序集中定义的。 您必须添加对程序集“ThirdPartyAssembly”的引用吗? - Why am I getting: The type 'IThirdParty' is defined in an assembly that is not referenced. You must add a reference to assembly 'ThirdPartyAssembly'? C#出现错误:在未引用的程序集中未定义类型“ Indirect.Class”。 必须添加对程序集“间接”的引用 - C# Getting Error: Type “Indirect.Class” Not Defined In an Assembly Not Referenced . Must Add a reference to assembly “Indirect” 为什么会得到“在未引用的程序集中定义了xxx类型”? - Why do I get “type xxx is defined in an assembly that is not referenced”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM