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