Why just Description? Look at all the assembly attributes; you could have them auto-generated and found in your file "AssemblyInfo.vb". There are
AssemblyCompanyAttribute
,
AssemblyCopyrightAttribute
and so on — see
http://msdn.microsoft.com/en-us/library/ms973231.aspx[
^].
You can retrieve all the values of these attributes and use them in your application; for example, you can present some of this information in your "About" dialog; you can also use some of them in text messages; I usually use
AssemblyProductAttribute
(it is used by the property
System.Windows.Forms.Application.ProductName
).
Look at the class definitions for all these attributes: they have
AttributeTargets.Assembly
; it is defined by the attribute
AttributeUsageAttribute
applied to other attributes. So, you first need to get the instance of the Assembly of your code. You can use
System.Reflection.Assembly.GetCallingAssembly
,
System.Reflection.Assembly.GetExecutingAssembly
or
System.Reflection.Assembly.GetEntryAssembly
, see
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[
^].
In most cases, I'll recommend to use
GetEntryAssembly
, as usually you need to retrieve the assembly attributes of the assembly used as a main application assembly, not one of the class libraries (however, you can get assembly information for all of the assemblies used in your solution(s)). Using this method allows you to use the code retrieving assembly information in some class library in a separate universal assembly and in this way re-use this code for different assemblies, getting different results depending on the assembly having the application entry point ("entry assembly").
When you got an instance of the assembly, use the method
System.Reflection.Assembly.GetCustomAttributes(Type, Boolean)
for each of the attribute types you used in your "AssemblyInfo.vb", see
http://msdn.microsoft.com/en-us/library/88d17d13.aspx[
^]. It will return the array of attributes (possibly empty), but this array will be of length 1 (or 0), so you need and can get only one attribute instance per attribute type. You will need to type cast the result to the same attribute type you used in the call to
System.Reflection.Assembly.GetCustomAttributes(Type, Boolean)
. Each of the attribute types gives you access to the value you used for application of the attributes to your assembly in your file "AssemblyInfo.vb".
This is the complete solution. Just do it.
—SA