编译器错误 C3097

“attribute”:特性必须使用“assembly:”或“module:”确定范围

未正确使用全局特性。

有关更多信息,请参见 User-Defined Attributes

示例

以下示例生成 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 {};