none
is there a way to display your vision like 1.2 or 1.2.1 RRS feed

  • Question

  • i have a application and i don't want to have a it display like 1.0.0.1

    is there a way i can display it like 1.2 or 1.2.1 something simple like that sorry if this is a stupid question just thought i would ask ? 

    Saturday, August 19, 2017 1:05 PM

All replies

  • Try this:

             var appVersion = "1.2.1.1";
    
                var appVersionThree = appVersion.Substring(0, appVersion.LastIndexOf('.'));
                var appVersionTwo = appVersionThree.Substring(0, appVersionThree.LastIndexOf('.'));
                Console.WriteLine(appVersionTwo);
                Console.WriteLine(appVersionThree);
                Console.ReadLine();

    Saturday, August 19, 2017 1:29 PM
  • Try this:

             var appVersion = "1.2.1.1";
    
                var appVersionThree = appVersion.Substring(0, appVersion.LastIndexOf('.'));
                var appVersionTwo = appVersionThree.Substring(0, appVersionThree.LastIndexOf('.'));
                Console.WriteLine(appVersionTwo);
                Console.WriteLine(appVersionThree);
                Console.ReadLine();

    that works thank you only thing i would as is there a way to get that to work with the version that the program is or do i have to manually update it each time i go up a version

    Saturday, August 19, 2017 3:24 PM
  • I am giving you a summary from this german post:
    https://social.msdn.microsoft.com/Forums/vstudio/de-DE/de03fe08-ac1e-416f-828d-81156ed82f12/programmversion-auslesen?forum=vsexpressde

    You can get the AssemblyVersion with "My.Application.ProductVersion".

    With ClickOnce - after it is deployed - you can also get the DeploymentVersion with "My.Application.Deployment.CurrentVersion".

    You could also try to read out the AssemblyFileVersion via (VB code, please translate):

    Dim lFileInfo As FileVersionInfo = _
     FileVersionInfo.GetVersionInfo(GetType(Me).Assembly.Location)
    But in the end, the Version number is just a compile or runtime constant (const or readonly that is set during load).

    Remember to mark helpfull answers as helpfull and close threads by marking answers.

    Saturday, August 19, 2017 7:15 PM
  • Hello elfenliedtopfan2,

    You could change the version assembly from code:

    [assembly: AssemblyVersion("2.0.1")]
    namespace ConsoleApp4
    {
        public class Program
        {
            static void Main(string[] args)
            {  
                Version ver = typeof(Program).Assembly.GetName().Version;
    
                Console.WriteLine("The version is {0} .", ver );
            }
        }
    }


    Or you could change the version manually.The following link will guide you to achieve it.

    https://www.codeproject.com/Articles/328977/The-Right-Way-to-Version-Your-Assemblies

    Best regards,
    feih_7


    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 MSDNFSF@microsoft.com.

    Monday, August 21, 2017 10:27 AM
    Moderator
  • Version numbers are always 4 parts in Windows. Some systems (like NuGet and GitHub) may use 3 parts but your assemblies will always be 4. But versioning is a semantic thing anyway so even though your product, file and assembly version is 4 parts doesn't mean you need to use them. If you look at the versions for binaries that are showing you 3 parts you'll find they actually have 4. The last digit tends to be 0 in this case but it is still there.

    Also note that there is an Informational Version as well which is an arbitrary string. This is what is often shown when getting the string version. Most apps tend to put semantic info like "Debug", "RC" or even "Beta". You can put whatever you want. If you want 3 part versions (outside product, file and assembly) then you can set the informational version to the 3 part value you want.

    Michael Taylor
    http://www.michaeltaylorp3.net

    • Proposed as answer by Fei HuModerator Wednesday, September 6, 2017 8:54 AM
    Monday, August 21, 2017 3:09 PM
    Moderator