簡體   English   中英

未使用(和引用)的程序集上的程序集引用錯誤,為什么會出現此錯誤?

[英]Assembly reference error on not used (and referenced) assembly, why do I this error?

在我的解決方案中,我有三個項目(Web,業務和數據)都針對.net 4.5.1。 Web參考業務和業務參考數據。

我需要根據應用程序啟動在這三個項目中執行初始化方法。 因此,我在所有項目中都創建了一個Boot類。

Business中的Boot類繼承自Data中的Boot類,而Web中的Boot類繼承於Business中的Boot類

所以我有這段代碼:

在數據項目中:

namespace Data
{
    public class Boot
    {
        public Boot() 
        {
            // init execution
        }
    }
}

在業務項目中:

namespace Business
{
    public class Boot : Data.Boot
    {
        public Boot() : base()
        {
            // init execution
        }
    }
}

在Web項目中:

namespace Web
{
    public class Boot : Business.Boot
    {
        public Boot() : base()
        {
            // init execution
        }
    }
}

當我編譯時,Web項目中的Boot類出現錯誤:

類型“ Data.Boot”是在未引用的程序集中定義的。 您必須添加對程序集'Data,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'的引用

而且我不明白為什么我的Web項目需要引用我的Data項目。它從不直接使用Data.Boot。

您必須在Web和業務項目中添加對數據項目的引用。 在您的情況下,您的Web層取決於業務層數據層。

總結一下:

  • Web項目引用業務項目和數據項目
  • 業務參考數據項目

您必須檢查在業務項目中是否引用了數據DLL,如果是,則必須清理解決方案並重新生成它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM