Click here to Skip to main content
13,297,048 members (56,795 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


9 bookmarked
Posted 25 Mar 2012

Get all Assembly Information

, 27 Mar 2012
Rate this:
Please Sign up or sign in to vote.
This tip shows how to get quickly all Information of an Assembly


With assembly attributes it is possible to specify assembly meta information such as product title or version, either automatically by Visual Studio (see here for more information) or manually by editing the file "AssemblyInfo.cs" in the project folder "Properties".

With the class provided with this tip these attributes can be easily read from any assembly.

To obtain information of an assembly the constructor of AssemblyInfo can be used by passing the specific assembly.

If the corresponding assembly attribute to a property is not found, <code>null will be returned.


This example will write all assembly information of the entry assembly to the console.

AssemblyInfo entryAssemblyInfo = new AssemblyInfo(Assembly.GetEntryAssembly());
Console.WriteLine("Company: " + entryAssemblyInfo.Company);
Console.WriteLine("Copyright: " + entryAssemblyInfo.Copyright);
Console.WriteLine("Description: " + entryAssemblyInfo.Description);
Console.WriteLine("Product: " + entryAssemblyInfo.Product);
Console.WriteLine("ProductTitle: " + entryAssemblyInfo.ProductTitle);
Console.WriteLine("Version: " + entryAssemblyInfo.Version);

The Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;

namespace HdSystemLibrary.Reflection
    public class AssemblyInfo
        public AssemblyInfo(Assembly assembly)
            if (assembly == null)
                throw new ArgumentNullException("assembly");
            this.assembly = assembly;

        private readonly Assembly assembly;

        /// <summary>
        /// Gets the title property
        /// </summary>
        public string ProductTitle
                return GetAttributeValue<AssemblyTitleAttribute>(a => a.Title, 

        /// <summary>
        /// Gets the application's version
        /// </summary>
        public string Version
                string result = string.Empty;
                Version version = assembly.GetName().Version;
                if (version != null)
                    return version.ToString();
                    return "";

        /// <summary>
        /// Gets the description about the application.
        /// </summary>
        public string Description
            get { return GetAttributeValue<AssemblyDescriptionAttribute>(a => a.Description); }

        /// <summary>
        ///  Gets the product's full name.
        /// </summary>
        public string Product
            get { return GetAttributeValue<AssemblyProductAttribute>(a => a.Product); }

        /// <summary>
        /// Gets the copyright information for the product.
        /// </summary>
        public string Copyright
            get { return GetAttributeValue<AssemblyCopyrightAttribute>(a => a.Copyright); }

        /// <summary>
        /// Gets the company information for the product.
        /// </summary>
        public string Company
            get { return GetAttributeValue<AssemblyCompanyAttribute>(a => a.Company); }

        protected string GetAttributeValue<TAttr>(Func<TAttr, 
          string> resolveFunc, string defaultResult = null) where TAttr : Attribute
            object[] attributes = assembly.GetCustomAttributes(typeof(TAttr), false);
            if (attributes.Length > 0)
                return resolveFunc((TAttr)attributes[0]);
                return defaultResult;


This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


About the Author

Henning Dieterichs
Germany Germany
Presently I am a student of computer science at the Karlsruhe Institute of Technology in Germany.

You may also be interested in...


Comments and Discussions

QuestionRegarding full workspace Pin
Member 114944793-Mar-15 3:01
memberMember 114944793-Mar-15 3:01 
Suggestionnamespace screwed up, remove the static members... Pin
Andreas Gieriet25-Mar-12 18:17
memberAndreas Gieriet25-Mar-12 18:17 
GeneralRe: namespace screwed up, remove the static members... Pin
Henning Dieterichs25-Mar-12 21:50
memberHenning Dieterichs25-Mar-12 21:50 
GeneralRe: namespace screwed up, remove the static members... Pin
Andreas Gieriet25-Mar-12 22:43
memberAndreas Gieriet25-Mar-12 22:43 
GeneralRe: namespace screwed up, remove the static members... Pin
Henning Dieterichs27-Mar-12 6:18
memberHenning Dieterichs27-Mar-12 6:18 
Thanks again for your detailed response!
I've updated the article with your improvements.

I know the possibility with x:Arguments, but this feature is not available before .Net 4.0. As Windows 7 comes only with 3.5 and I don't want my users to install a complete framework only for my stand-alone tool, I have to use the features coming with .Net 3.5.

And of course, the namespace is not the same as the assembly name, I did a typo.

If you find spelling- or grammer-mistakes, please let me know, so that I can correct them (at least for me) - english is not my first language...

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
Web04 | 2.8.171207.1 | Last Updated 27 Mar 2012
Article Copyright 2012 by Henning Dieterichs
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid