C# Error CS1613 – The managed coclass wrapper class ‘{0}’ for interface ‘{1}’ cannot be found (are you missing an assembly reference?)

C# Error

CS1613 – The managed coclass wrapper class ‘{0}’ for interface ‘{1}’ cannot be found (are you missing an assembly reference?)

Reason for the Error & Solution

The managed coclass wrapper class ‘class’ for interface ‘interface’ 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 or 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;  
  
[Guid("1FFD7840-E82D-4268-875C-80A160C23296")]  
[ComImport()]  
[CoClass(typeof(A))]  
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  
   }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...