共用方式為


編譯器錯誤 C3097

「屬性」:必須以 '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 {};