Assembly file version, just Major and Minor


  • I use these lines to get the Assembly file version:

                System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
                string LVersion = fvi.FileVersion;
                LauncherVersion.Content = "v" + LVersion;
    but i want to have just Major And Minor version, not Build and Revision.

    Monday, April 24, 2017 3:22 PM

All replies

  • Hi Ailincai Rares,

    Thank you for posting here and sorry for late reply.

    For your question, please try the following code.

     System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                Version version = assembly.GetName().Version;
                Console.WriteLine("Major:{0},Minor:{1},Build:{2},Revision:{3}", version.Major, version.Minor, version.Build, version.Revision);

    I hope this would be helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, May 1, 2017 6:55 AM
  • FYI there are several different versions associated with an assembly. The assembly itself has an assembly version which is the product version and generally consists of just the major/minor number. That is what Wendy's code gives you. The file has a separate file version which is generally the full version as generated by the build. It is used for things like installers that need to determine if a file is newer or older than another version. Additionally there is the AssemblyInfoVersion which is the string representation of the version number and can contain additional information (such as RC, Beta, etc). This is the version that Explorer will generally show by default when you hover over it.

    Given the version (VersionInfo) you can access the individual pieces using the corresponding properties.

    Michael Taylor

    Monday, May 1, 2017 2:44 PM