The AssemblyDescription attribute is to provide some detailed information about a .NET assembly. The AssemblyCompany attribute indicates the company who produced the assembly. They are also common enough but do not find their place in the file Properties UI of the Explorer program.
If necessary, of course, we can find out such information programmatically by ourselves. Here is some sample code to print out the two pieces of assembly information along with some others that we have introduced previously:
private void PrintAssemblyInfo()
{
StringDictionary asmValues = GetAssemblyInfo(Assembly.GetEntryAssembly());
string str = string.Empty;
foreach (DictionaryEntry v in asmValues)
{
str += string.Format("{0}: {1}\n", v.Key, v.Value);
}
MessageBox.Show(str, "Assembly Information");
}
private StringDictionary GetAssemblyInfo(Assembly asm)
{
// Get ALL attributes from AssemblyInfo.cs
Object[] atts = asm.GetCustomAttributes(false);
StringDictionary asmValues = new StringDictionary();
foreach (Object obj in atts)
{
if (obj is AssemblyTitleAttribute)
asmValues.Add("Title", (obj as AssemblyTitleAttribute).Title);
else if (obj is AssemblyDescriptionAttribute)
asmValues.Add("Description", (obj as AssemblyDescriptionAttribute).Description);
else if( obj is AssemblyConfigurationAttribute)
asmValues.Add("Configuation", (obj as AssemblyConfigurationAttribute).Configuration);
else if( obj is AssemblyCompanyAttribute)
asmValues.Add("Company", (obj as AssemblyCompanyAttribute).Company);
else if(obj is AssemblyProductAttribute)
asmValues.Add("Product", (obj as AssemblyProductAttribute).Product);
else if(obj is AssemblyCopyrightAttribute)
asmValues.Add("Copyright", (obj as AssemblyCopyrightAttribute).Copyright);
else if(obj is AssemblyTrademarkAttribute)
asmValues.Add("Trademark", (obj as AssemblyTrademarkAttribute).Trademark);
else if( obj is AssemblyCultureAttribute)
asmValues.Add("Culture", (obj as AssemblyCultureAttribute).Culture);
}
return asmValues;
}
Here is the output:
As can be noticed, the core method is the Assembly.GetCustomAttributes(). It collects all assembly custom attributes from the specified .NET assembly.
AssemblyInfo Updater of RevitAddinWidget can help review popular assembly information of all available projects in a Visual Studio solution and update the information conveniently and flexibly in a single central place.
Recent Comments