Edit

Share via


Compiler Error CS0596

The Guid attribute must be specified with the ComImport attribute

The Guid attribute must be present when using the ComImport attribute.

The following sample generates CS0596:

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