Managed C++ Assembly Attributes

2020-07-08 08:13发布

问题:

Is there a way to add assembly attributes to a Managed C++ assembly? In a typical C# project, there is usually a line of code in the AssemblyInfo.cs file like the following one:

[assembly: AssemblyTitle("Some Assembly")]

I have a private assembly attribute that I want to add (not one of the version attributes that could be added through a resource file), and I am not sure if this is possible.

回答1:

It is possible - the easy way is to add an AssemblyInfo.cpp file and put:

#include attributes.h //your attribute decl
[assembly: MyCustomAttribute()];

It can be in any file you want, though.

edit - added required semicolon for assembly attribute