Teilen über


Compilerfehler C3450

„Typ“: ist kein Attribut. [System::AttributeUsageAttribute] oder [Windows::Foundation::Metadata::AttributeUsageAttribute] darf nicht angegeben werden.

Bemerkungen

Ein benutzerdefiniertes verwaltetes Attribut muss von AttributeCollection erben. Ein Windows-Runtime-Attribut muss im Windows::Foundation::Metadata-Namespace definiert sein.

Weitere Informationen finden Sie unter User-Defined Attributes.

Beispiel

Im folgenden Beispiel wird C3450 generiert und veranschaulicht, wie sie behoben werden kann.

// 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 {};