Compiler Error C3099

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C3099.

keyword': use [System::AttributeUsageAttribute] for managed attributes; use [Windows::Foundation::Metadata::AttributeUsageAttribute] for WinRT attributes

Use AttributeUsageAttribute to declare /clr attributes. Use Windows::Foundation::Metadata::AttributeUsageAttribute to declare Windows Runtime attributes.

For more information about /CLR attributes, see User-Defined Attributes. For supported attributes in Windows Runtime, see Windows.Foundation.Metadata namespace

The following sample generates C3099 and shows how to fix it.

// C3099.cpp  
// compile with: /clr /c  
using namespace System;  
[usage(10)]   // C3099  
// try the following line instead  
// [AttributeUsageAttribute(AttributeTargets::All)]  
ref class A : Attribute {};  

Show: