Share via


Assembly Version - Odds and Ends

 

What's the Assembly Version Good For?

Using assembly version is a wonderful way for someone to help maintain and support their applications.  It is defined in the AssemblyInfo.cs file through an attribute.  You can manually update it or have a auto incrementing process to control your assembly version.  It is a good idea to display it on an 'About Dialog' so users can report it when they suggest new features or find bugs.

How Do I Retrieve the Assembly Version?

From a console application the version number can be retrieved by:

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version

And from an application that loads the System.Windows.Forms library it can by retrieved by:

new Version(Application.ProductVersion)

Both of these calls will take about 10ms to run the first time, but the results will be cached for future calls.

Tell Me Something Weird!

If you don't define an assembly version the first method will return 0.0.0.0 and the 2nd method will return 1.0.0.0.

Comments