Edit

Share via


Compiler Warning (level 1) CS1682

Reference to type 'type' claims it is nested within 'nested type', but it could not be found

This error arises when you import references that do not agree with other references or with code you have written. A common way to get this error is to write code that refers to a class in metadata, and then you either delete that class or modify its definition.

Example 1

C#
// CS1682.cs  
// compile with: /target:library /keyfile:mykey.snk  
public class A {  
   public class N1 {}  
}  

Example 2

C#
// 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();  
   }  
}  

Example 3

C#
// CS1682_c.cs  
// compile with: /target:library /keyfile:mykey.snk /out:CS1682.dll  
public class A {  
   public void M1() {}  
}  

Example 4

The following sample generates CS1682.

C#
// CS1682_d.cs  
// compile with: /reference:CS1682.dll /reference:CS1682_b.dll /W:1  
// CS1682 expected  
class Tester {  
   static void Main()  
   {  
      Ref.A1().M1();  
   }  
}