編譯器錯誤 C3451
更新:2007 年 11 月
錯誤訊息
'attribute': 無法將 Unmanaged 屬性套用至 'type'
C++ 屬性無法套用至 CLR 型別。如需詳細資訊,請參閱 C++ Attributes Reference。
如需詳細資訊,請參閱 User-Defined Attributes。
對 Visual C++ 2005 的編譯器完成一致性處理後可能會發生這項錯誤:在使用 CLR 程式設計的使用者定義屬性上不再允許 uuid (C++ Attributes) 屬性。請改用 GuidAttribute。
如需詳細資訊,請參閱 Visual C++ 2005 編譯器的重大變更。
範例
下列範例會產生 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 {};