Compiler Error C3114
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3114.
argument': not a valid named attribute argument
In order for an attribute class data member to be a valid named argument, it must not be marked static, const, or literal. If a property, the property must not be static and must have get and set accessors.
For more information, see property and User-Defined Attributes.
The following sample generates C3114.
// C3114.cpp
// compile with: /clr /c
public ref class A : System::Attribute {
public:
static property int StaticProp {
int get();
}
property int Prop2 {
int get();
void set(int i);
}
};
[A(StaticProp=123)] // C3114
public ref class R {};
[A(Prop2=123)] // OK
public ref class S {};
Show: