Marks a class as being an externally implemented COM coclass.
[comimport]
Class declarations.
comimport is a single-use attribute. comimport is an alias for System.InterOp.ComImportAttribute.
A class with the comimport attribute must also have a guid attribute. A comimport class must be derived directly from object and must not have any members. Creating an instance of a comimport class using new is equivalent to calling CoCreateInstance.
[comimport, guid("E436EBB3-524F-11CE-9F53-0020AF0BA770")] class FilgraphManager { // cannot have any members here // NOTE: the C# compiler will add a default parameterless constructor } class MainClass { public static void Main() { // Create an instance of a COM classic coclass - calls // CoCreateInstance(E436EBB3-524F-11CE-9F53-0020AF0BA770, // NULL, CLSCTX_ALL, // IID_IUnknown, &f) // returns null on failure. FilgraphManager f = new FilgraphManager(); } }
C# Attributes | COM InterOp Tutorial