ProgramInfo class: Retrieving custom assembly attributes in C# for Name, Copyright, and Version

There may exist a need to programmatically retrieve a program’s assembly attributes to provide product information to a user. This can be problematic if you are not using the System.Windows.Forms.Application library. Retrieving this information however is still possible using commands within the System.Reflection.Assembly class. I have encapsulated the most commonly used attributes in the following class called ProgramInfo. The class file can be added to your project; class properties can be called statically for ease of use.

Download:
ProgramInfo.zip

Code Version: 0.1

I use this class in almost all of my Console-based applications as it allows me to display product information for the executable as a command line option.

Example:

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("{0} {1}\n{2}",
                            Application.ProgramInfo.ProductName,
                            Application.ProgramInfo.FileVersion,
                            Application.ProgramInfo.Copyright);
        Console.ReadKey(true);
    }
}

Tags: , , , ,

Leave a Comment

You must be logged in to post a comment.