Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading Assembly version information of WPF application

I am reading version information of my wpf application, but I am not getting the correct version as I have write in AssemblyInfo.cs file. In my file there is

[assembly: AssemblyVersion("0.1.001")] [assembly: AssemblyFileVersion("0.0.001")] 

I am reading version information using this code

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

I am getting this version 0.1.1.0 and it should be 0.1.001

Thanks

like image 537
Muhammad Akhtar Avatar asked Aug 23 '10 10:08

Muhammad Akhtar


People also ask

How do I find my assembly version?

"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.

What version of WPF do I have?

In Open, type regedit.exe. 3. The WPF version number is stored in the Version value.

What is assembly version and assembly file version?

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.

What is assembly versioning in C#?

The assembly's version number, which, together with the assembly name and culture information, is part of the assembly's identity. This number is used by the runtime to enforce version policy and plays a key part in the type resolution process at run time.


2 Answers

The properties Major, Minor, Build and Revision of class Version are of type int, not string. So when string from assembly version is parsed into Version class, the parts of this string will be converted to int representation. Also there are rule that first number of specified version string is Major component of Version:

"1" - 1.0.0.0 "1.2" - 1.2.0.0 "1.2.3" - 1.2.3.0 "1.2.3.4" 1.2.3.4 
like image 90
Eugene Cheverda Avatar answered Sep 23 '22 04:09

Eugene Cheverda


In the MSDN article, it says that:

All components of the version must be integers greater than or equal to 0

So it's either rounding up or removing trailing zeros to get a valid integer.

like image 21
Rox Avatar answered Sep 25 '22 04:09

Rox