CS0616 de erro do compilador

Mensagem de erro

'class' não é uma classe de atributos

Houve uma tentativa de usar uma classe de atributos não em um bloco de atributo.Todos os tipos de atributo precisam ser herdadas de System.Attribute.

Exemplo

O exemplo a seguir gera CS0616.

// CS0616.cs
// compile with: /target:library
[CMyClass(i = 5)]   // CS0616
public class CMyClass {}

O exemplo a seguir mostra como você pode definir um atributo:

// CreateAttrib.cs
// compile with: /target:library
using System;

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface)]
public class MyAttr : Attribute
{
   public int Name = 0;
   public int Count = 0;

   public MyAttr (int iCount, int sName)
   {
      Count = iCount;
      Name = sName;
   }
}

[MyAttr(5, 50)]
class Class1 {}

[MyAttr(6, 60)]
interface Interface1 {}