Click here to Skip to main content
13,512,246 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


7 bookmarked
Posted 23 Aug 2012

Changing Version Number Dynamically

, 23 Aug 2012
Rate this:
Please Sign up or sign in to vote.
Dynamic changing of version number using SolutionInfo.cs through out the application.


Changing the assembly version and assembly file version in AssemblyInfo.cs.

Guidelines to be followed

  • Step 1: List out common parameters and dynamically changing one from AssemblyInfo.cs which is   present under properties.
  • Step 2: Copy AssemblyInfo.cs and put it in root directory of Solution Explorer and rename it to SolutionInfo.cs.
  • Step 3: Put the Constant Parameters in SolutionInfo.cs and remove the remaining parameters.
  • //SolutionInfo.cs
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Security.Permissions;
    [assembly: AssemblyConfiguration("")]
    [assembly: AssemblyCompany("")]
    [assembly: AssemblyProduct("WindowsFormsCheckVersion")]
    [assembly: AssemblyCopyright("Copyright ©  2012")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: ComVisible(false)]
    [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyFileVersion("1.0.*")]
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    [assembly: AssemblyTitle("WindowsFormsCheckVersion")]
    [assembly: AssemblyDescription("")]
    [assembly: Guid("e2ff28a6-9772-4681-9778-d8e4bed68ce0")]
  • Step 4: Remove the parameters that are mentioned in SolutionInfo.cs.
  • Step 5: Create a new folder under Solution Explorer, name it to SolutionItem, and add the SolutionInfo.cs file to this folder.
  • Step 6: Now Right click on Project > Add >Existing Item >select the solutionInfo.cs file, and choose Add Link File.
  • (This has to be done to all projects where ever you need to change version Number)We need to keep it in mind that we should remove the parameters that are placed in SolutionInfo.cs.

    If you want to check that version has been changed at all places we can check it with DLL or we can get it through application code also.

    Assembly executingAssembly;
    AssemblyName executingAssemblyName;
    Version executingAssemblyVersion;
    executingAssembly = Assembly.GetEntryAssembly();
    executingAssemblyName = executingAssembly.GetName();
    executingAssemblyVersion = executingAssemblyName.Version;
    string assemblyVersion = executingAssemblyVersion.ToString(4);
    string path;
    path = System.IO.Path.GetDirectoryName(

Point to remember

Make sure that parameters that are placed under solutionInfo.cs should be removed in all AssemblyInfo.cs.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Purushotham Agaraharam
Software Developer (Senior) @ CSC
India India
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Organisation

8 members

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Christian Amado23-Aug-12 7:09
memberChristian Amado23-Aug-12 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180417.1 | Last Updated 23 Aug 2012
Article Copyright 2012 by Purushotham Agaraharam
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid