Reading Assembly version information of WPF application
Solution 1
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
Solution 2
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.
Muhammad Akhtar
Senior Software Engineer MCTS - Microsoft Certified Technology Specialist toakhtar - at - hotmail - .com Cell # : 00923014728930 View my MCP Certifications http://stackoverflow.com/tags/asp.net/topusers http://stackoverflow.com/search?tab=votes&q=user%3a97010%20%5basp.net%5d http://www.linkedin.com/profile/view?id=48514505&trk=tab_pro
Updated on August 24, 2020Comments
-
Muhammad Akhtar over 3 years
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 be0.1.001
Thanks