I have a reference to a type, for which I would like to retrieve the version number of the Assembly in which it is located.
What is the best way to do this?
"Assembly File Version" is what shows when you right-click on a file and go to "properties" then the "details" tab. They are not the same. I've found that the assembly version is what's used when determining the user. config location in AppData.
The version number is stored in the assembly manifest along with other identity information, including the assembly name and public key, as well as information on relationships and identities of other assemblies connected with the application.
The Product version of the assembly. This is the version you would use when talking to customers or for display on your website. This version can be a string, like '1.0 Release Candidate'. The AssemblyInformationalVersion is optional. If not given, the AssemblyFileVersion is used.
It's the version number used by framework during build and at runtime to locate, link, and load the assemblies. When you add reference to any assembly in your project, it's this version number that gets embedded.
you can use,
x.GetType().Assembly.GetName().Version
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