Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0617

'reference' is not a valid named attribute argument because it is not a valid attribute parameter type

An attempt was made to access a private member of an attribute class.

The following sample generates CS0617.

// CS0617.cs
using System;

[AttributeUsage(AttributeTargets.Struct | 
                AttributeTargets.Class |
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 {}

Community Additions

© 2015 Microsoft