编译器警告(等级 1)CS1682
对类型“type”的引用声称该类型嵌套在“nested type”中,但并未找到该类型
当导入的引用与其他引用或者编写的代码不一致时,会发生此错误。 发生此错误通常是因为编写了在元数据中引用类的代码,而此后删除了该类或修改了该类的定义。
// CS1682.cs
// compile with: /target:library /keyfile:mykey.snk
public class A {
public class N1 {}
}
// CS1682_b.cs
// compile with: /target:library /reference:CS1682.dll
using System;
public class Ref {
public static A A1() {
return new A();
}
public static A.N1 N1() {
return new A.N1();
}
}
// CS1682_c.cs
// compile with: /target:library /keyfile:mykey.snk /out:CS1682.dll
public class A {
public void M1() {}
}
下面的示例生成 CS1682。
// CS1682_d.cs
// compile with: /reference:CS1682.dll /reference:CS1682_b.dll /W:1
// CS1682 expected
class Tester {
static void Main()
{
Ref.A1().M1();
}
}