Compilerwarnung (Stufe 1) CS0684

Die mit „CoClassAttribute“ markierte interface-Schnittstelle wurde nicht mit „ComImportAttribute“ markiert.

Wenn Sie CoClassAttribute in einer Schnittstelle angeben, müssen Sie auch ComImportAttributeangeben.

Im folgenden Beispiel wird CS0684 generiert:

// CS0684.cs  
// compile with: /W:1  
using System;  
using System.Runtime.InteropServices;  
  
[CoClass(typeof(C))] // CS0684  
// try the following line instead  
// [CoClass(typeof(C)), ComImport]  
interface I  
{  
}  
  
class C  
{  
   static void Main() {}  
}