To retrieve a program’s Assembly information, you need to access the System.Reflection.Assembly class.
First, retrieve the object for the currently executing assembly:
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
Next, retrieve the desired attributes by calling GetCustomAttributes() with the respective attribute type:
object[] rgobjP = asm.GetCustomAttributes( typeof(System.Reflection.AssemblyProductAttribute), false); object[] rgobjV = asm.GetCustomAttributes( typeof(System.Reflection.AssemblyFileVersionAttribute), false);
If the attribute exists in the assembly, the object[] array has a length greater zero.
However, the AssemblyVersion (of type AssemblyVersionAttribute) is not accessible in this way, as iterating through the array
object[] rgobj = asm.GetCustomAttributes(false);
shows. Rather, you have to access the assembly’s asm.GetName().Version object.
See also this entry on codeproject with available source code.
Pingback: AssemblyVersion and AssemblyFileVersion « devioblog