Thursday, August 21, 2008

How to get C# Assembly GUID

How to get C# Assembly GUID using Reflection




public string AssemblyGuidString(System.Reflection.Assembly assembly)
{
object[] objects =
assembly.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);
if (objects.Length > 0)
{
return ((System.Runtime.InteropServices.GuidAttribute)objects[0]).Value;
}
else
{
return String.Empty;
}
}






keys: c#, assembly, reflection, guid, attributes