Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to find .Net assembly version

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 88
    Comment on it

    Whenever we create a project in visual studio, a file named AssemblyInfo is created by itself which contains the attributes used to define the version of assembly during compilation.

    Versioning an assembly helps to identify deployed assemblies and helps in troubleshooting as well.

    Assembly version consist of four blocks

     

    1. Major Version
    2.  Minor Version
    3. Build Number
    4. Revision

     

    Major Version is used for manually incrementing the version for major releases.

     

    Minor Version is incremented for minor releases.

     

    Build Number is incremented automatically as part of every build.

     

    Revision Is incremented for patches and hotfixes to build release into production environment. It is set to zero for first release of any major or minor version.

     

    We can find the version of an assemble using C# or VB code in .Net.

     

    We can find version of executing assembly (Current assembly) or load any other assembly from any location to find its version.

     

    Here is the code sample for finding assembly version of executing assembly

    C#

    Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;

    VB

    Dim assemblyVersion As Version = Assembly.GetExecutingAssembly().GetName().Version

    Here is the code for finding assembly version for other .Net assemblies

    C#

    Version assemblyVersion = Assembly.LoadFile(@"Your Assembly Path").GetName().Version;

    VB

    Dim assemblyVersion As Version = Assembly.LoadFile("Your Assembly Path ").GetName().Version

    In above code we are using Assembly class methods to find assembly version. Assembly class resides in System.Reflection namespace.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: