How do I get my .NET Application's Assembly Information?

Similar to Visual Basic 6's App object .NET offers the Application object which exposes properties for the CompanyName, ProductVersion and ProductName values set in the AssemblyInfo.vb or AssemblyInfo.cs file. For Example:

    lblCompany.Text = "Company Name: " & Application.CompanyName.Trim
    lblProduct.Text = "Product Name: " & Application.ProductName.Trim
    lblVersion.Text = "Version " & Application.ProductVersion.Trim

Other properties such as Assembly Title and Assembly Description must be retrieved using the System.Reflection Namespace:

    Imports System.Reflection

    Dim aAssembly As [Assembly] = _

    Dim aDescAttr As AssemblyDescriptionAttribute = _
        AssemblyDescriptionAttribute.GetCustomAttribute( _
        aAssembly, GetType(AssemblyDescriptionAttribute))

    Dim aTitleAttr As AssemblyTitleAttribute = _
        AssemblyTitleAttribute.GetCustomAttribute( _
        aAssembly, GetType(AssemblyTitleAttribute))


Note: Option Strict must be Off.

C# code:

    using System.Reflection;

    lblCompany.Text = "Company Name: " + Application.CompanyName.Trim();
    lblProduct.Text = "Product Name: " + Application.ProductName.Trim();
    lblVersion.Text = "Version " + Application.ProductVersion.Trim();

    AssemblyDescriptionAttribute desc;
    AssemblyTitleAttribute title;
    Assembly aAssembly = Assembly.GetExecutingAssembly();

    desc = (AssemblyDescriptionAttribute) 
            aAssembly, typeof (AssemblyDescriptionAttribute));
    title = (AssemblyTitleAttribute) 
		aAssembly, typeof (AssemblyTitleAttribute));


You can also retrieve version, CopyRight, Trademark, Company Name, and other information from your assembly using the following VB Code:

    Imports System.Diagnostics.FileVersionInfo
    Imports System.Reflection.Assembly

    Dim vi As FileVersionInfo = GetVersionInfo(GetExecutingAssembly.Location)

    Console.WriteLine("Major Version: " & vi.ProductMajorPart().ToString())
    Console.WriteLine("Minor Version: " & vi.ProductMinorPart().ToString())
    Console.WriteLine("Build Number: " & vi.ProductBuildPart ().ToString())
    Console.WriteLine("Product Versionr: " & vi.ProductVersion().ToString())

To retrieve the physical folder location of the your DLL or Exe that is executing, use this VB code:

    Dim path as String = _

About TheScarms
About TheScarms

Sample code
version info

If you use this code, please mention ""

Email this page

© Copyright 2024 TheScarms
Goto top of page