Errore del compilatore C3450
'type': non è un attributo; impossibile specificare [System::AttributeUsageAttribute] o [Windows::Foundation::Metadata::AttributeUsageAttribute]
Un attributo gestito definito dall'utente deve ereditare da AttributeCollection. Un attributo di Windows Runtime deve essere definito nello spazio dei nomi Windows::Foundation::Metadata
.
Per altre informazioni, vedere User-Defined Attributes.
Esempio
L'esempio seguente genera l'errore C3450 e mostra come risolverlo.
// C3450.cpp
// compile with: /clr
// C3450 expected
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
public ref class MyClass {};
class MyClass2 {};
[attribute(AttributeTargets::All)]
ref struct AtClass {
AtClass(Type ^) {}
};
[attribute(AttributeTargets::All)]
ref struct AtClass2 {
AtClass2() {}
};
// Apply the AtClass and AtClass2 attributes to class B
[AtClass(MyClass::typeid), AtClass2]
[AttributeUsage(AttributeTargets::All)]
// Delete the following line to resolve.
ref class B {};
// Uncomment the following line to resolve.
// ref class B : Attribute {};