Freigeben über


Compilerfehler C3097

„attribute“: Der Gültigkeitsbereich des Attributs muss mit „assembly:“ oder „module:“ festgelegt werden

Ein globales Attribut wurde nicht ordnungsgemäß verwendet.

Weitere Informationen finden Sie unter User-Defined Attributes.

Beispiel

Im folgenden Beispiel wird C3097 generiert:

// C3097.cpp
// compile with: /clr /c
using namespace System;

[AttributeUsage(AttributeTargets::All, AllowMultiple = true)]
public ref class Attr : public Attribute {
public:
   Attr(int t) : m_t(t) {}
   int m_t;
};

[Attr(10)];   // C3097
[assembly:Attr(10)];   // OK

[Attr(10)]   // OK
public ref class MyClass {};