Compiler Error C3451
TOC
Collapse the table of content
Expand the table of content

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 (C++ Component Extensions).

This error can be generated as a result of compiler conformance work that was done for Visual C++ 2005: the uuid (C++ Attributes) 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 {};
Show:
© 2016 Microsoft