Compartir a través de


Error del compilador C3097

'attribute': el ámbito del atributo debe ser 'assembly:' o 'module:'.

Un atributo global se usó incorrectamente.

Para obtener más información, consulte User-Defined Attributes.

Ejemplo

El ejemplo siguiente genera la advertencia C3097.

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