Get Assembly GUID - CSharp System.Reflection

CSharp examples for System.Reflection:Assembly

Description

Get Assembly GUID

Demo Code

// The MIT License
using System.Runtime.InteropServices;
using System.Reflection;
using System.Linq;
using System;//from  w  w w .j a  v a 2 s  .c  o m

public class Main{
        public static string GetAssemblyGUID(this Assembly assembly)
        {
            var query = from guids in assembly.GetCustomAttributes<GuidAttribute>()
                        select guids;

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

            return "";
        }
}

Related Tutorials