Errore del compilatore CS0617

Aggiornamento: novembre 2007

Messaggio di errore

'riferimento' non è un argomento denominato valido dell'attributo poiché non è un tipo di parametro valido per l'attributo
'reference' is not a valid named attribute argument because it is not a valid attribute parameter type

È stato effettuato un tentativo di accedere a un membro private di una classe attribute.

Esempio

Il seguente codice di esempio genera l'errore CS0617.

// CS0617.cs
using System;

[AttributeUsage(AttributeTargets.Struct | 
                AttributeTargets.Class |
                AttributeTargets.Interface)]
public class MyClass : Attribute
{
   public int Name;

   public MyClass (int sName)
   {
      Name = sName;
      Bad = -1;
      Bad2 = -1;
   }

   public readonly int Bad;
   public int Bad2;
}

[MyClass(5, Bad=0)] class Class1 {}   // CS0617
[MyClass(5, Bad2=0)] class Class2 {}