Muokkaa

Jaa


Compiler Error C3451

'attribute': cannot apply unmanaged attribute to 'type'

A C++ attribute cannot be applied to a CLR type. See C++ Attributes Reference for more information.

For more information, see User-Defined Attributes.

This error can be generated as a result of compiler conformance work that was done for Visual Studio 2005: the uuid attribute is no longer allowed on a user-defined attribute using CLR programming. Use GuidAttribute instead.

Example

The following sample generates 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 {};