Share via


Compiler Error CS0669

A class with the ComImport attribute cannot have a user-defined constructor

The COM interop layer in the common language runtime supplies the constructor for ComImport classes. Consequently, a COM object can be used as a managed object in the runtime.

The following sample generates CS0669:

// CS0669.cs
using System.Runtime.InteropServices;
[ComImport, Guid("00000000-0000-0000-0000-000000000001")]
class TestClass
{
   TestClass()   // CS0669, delete constructor to resolve
   {
   }

   public static void Main()
   {
   }
}