共用方式為


編譯器警告 (層級 1) CS0684

更新:2007 年 11 月

錯誤訊息

'interface' 介面標示為 'CoClassAttribute',但沒有標示為 'ComImportAttribute'

如果在介面上指定 CoClassAttribute,則必須同時指定 ComImportAttribute

下列範例會產生 CS0684:

// 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() {}
}