Method for Application Version on a Console Utility App

Assembly.GetExecutingAssembly().GetName().Version

Also, you can still use the class, you just have to reference the containing assembly. It's no biggie.


Assembly.GetExecutingAssembly().GetName().Version is not the same as Application.ProductVersion (but may be good enough depending on your environment.

As can be seen with Lutz Reflector, Application.ProductVersion first attempts to use the AssemblyInformationalVersion attribute from Assembly.GetEntryAssembly() if it's present, and if GetEntryAssembly() is not null.

Otherwise it uses the file version of the executable file.

I don't see any reason not to use Application.ProductVersion in a console application.

Tags:

C#

.Net

Console