更新:2007 年 11 月
错误消息
无法解析由类型“type”引用的程序集“assembly”中的基类或接口“class”
用 /reference 从文件中导入的类是从某个类派生的,或者找不到它实现的接口。如果没有使用 /reference 将所需的 DLL 也包括在编译中,则可能发生这种情况。
有关更多信息,请参见“添加引用”对话框和 /reference(导入元数据)(C# 编译器选项)。
示例
// CS0011_1.cs
// compile with: /target:library
public class Outer
{
public class B { }
}
第二个文件创建一个 DLL,它定义从前一个示例中创建的类 B 派生的类 C。
// 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();
}
}