Get Assembly Version - CSharp System.Reflection

CSharp examples for System.Reflection:Assembly

Description

Get Assembly Version

Demo Code

// The MIT License
using System.Runtime.InteropServices;
using System.Reflection;
using System.Linq;
using System;/* ww  w.  j a  v  a  2 s .com*/

public class Main{
        public static string GetAssemblyVersion(this Assembly assembly)
        {
            var query = from versions in assembly.GetCustomAttributes<AssemblyVersionAttribute>()
                        select versions;

            if(1 == query.Count())
            {
                return query.First().Version;
            }

            return "";
        }
}

Related Tutorials