共用方式為


編譯器錯誤 CS0596

更新:2007 年 11 月

錯誤訊息

必須同時指定 Guid 屬性和 ComImport 屬性

使用 ComImport 屬性 (Attribute) 時,必須存在 Guid 屬性。

下列範例會產生 CS0596:

// CS0596.cs
using System.Runtime.InteropServices;

namespace x
{
   [ComImport]   // CS0596
   // try the following line to resolve this CS0596
   // [ComImport, Guid("00000000-0000-0000-0000-000000000001")]
   public class a
   {
   }

   public class b
   {
      public static void Main()
      {
      }
   }
}