共用方式為


編譯器錯誤 CS0011

更新:2007 年 11 月

錯誤訊息

無法解析型別 'type' 所參考組件 'assembly' 中的基底類別或介面 'class'

使用 /reference 從檔案匯入的類別是衍生自某個類別,或實作找不到的介面。如果所需的 DLL 未同時包含在使用 /reference 的編譯中,便可能會發生這個錯誤。

如需詳細資訊,請參閱加入參考對話方塊/reference (匯入中繼資料) (C# 編譯器選項)

範例

// CS0011_1.cs
// compile with: /target:library

public class Outer 
{
   public class B { }
}

第二個檔案建立一個定義類別 C 的 DLL,該類別衍生自之前範例中所建立的類別 B。

// CS0011_2.cs
// compile with: /target:library /reference:CS0011_1.dll
// post-build command: del /f CS0011_1.dll
public class C : Outer.B {}

第三個檔案取代第一個步驟所建立的 DLL,並省略內部類別 B 的定義。

// CS0011_3.cs
// compile with: /target:library /out:cs0011_1.dll
public class Outer {}

最後,第四個檔案參考第二個範例中定義的類別 C,其衍生自現在已遺漏的類別 B。

下列範例會產生 CS0011。

// CS0011_4.cs
// compile with: /reference:CS0011_1.dll /reference:CS0011_2.dll
// CS0011 expected

class M
{
   public static void Main()
   {
      C c = new C();
   }
}

請參閱

參考

加入參考對話方塊

/reference (匯入中繼資料) (C# 編譯器選項)