This documentation is archived and is not being maintained.

Compiler Error CS1613

The managed coclass wrapper class 'class' for interface 'interface' is invalid or cannot be found (are you missing an assembly reference?)

An attempt was made to instantiate a COM object from an interface. The interface has the ComImport and CoClass attributes, but the compiler cannot find the type given for the CoClass attribute.

To resolve this error, you can try one of the following:

  • Add a reference to the assembly that has the coclass (most of the time the interface and coclass should be in the same assembly). See /reference or Add Reference Dialog Box for information.
  • Fix the CoClass attribute on the interface.

The following sample demonstrates correct usage of CoClassAttribute:

// CS1613.cs
using System;
using System.Runtime.InteropServices;

public interface IA{}
public class A : IA {}

public class AA
   public static void Main()
      IA i;
      i = new IA(); // This is equivalent to new A().
                    // because of the CoClass attribute on IA