共用方式為


編譯器錯誤 C3451

'attribute': 無法將非受控屬性套用至 'type'

備註

無法將C++屬性套用至CLR類型。 如需詳細資訊,請參閱 C++屬性參考

如需詳細資訊,請參閱 User-Defined Attributes

這個錯誤可能是因為 Visual Studio 2005 完成的編譯程式一致性工作而產生: 使用 CLR 程式設計的使用者定義屬性不再允許 uuid 屬性。 請改用 GuidAttribute

範例

下列範例會產生 C3451。

// C3451.cpp
// compile with: /clr /c
using namespace System;
[ attribute(AttributeTargets::All) ]
public ref struct MyAttr {};

[ MyAttr, helpstring("test") ]   // C3451
// try the following line instead
// [ MyAttr ]
public ref struct ABC {};