How can I programmatically get the current product version in C#?
My code:
VersionNumber = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
I am getting VersionNumber=1.0.0.0, but the current version is 1.0.0.12.
You can set it explicitly by setting the assembly version within your assembly manifest. For more information, see Assembly Manifest. ProductVersion first looks to see if the assembly containing the main executable has the AssemblyInformationalVersion attribute on it.
There are three versions: assembly, file, and product. To get the product version:
using System.Reflection; using System.Diagnostics; Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fileVersionInfo.ProductVersion;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With