Diese Klasse liefert eine generische Liste mit allen Assemblies, die im Global Assembly Cache (GAC) installiert sind.
/// <summary>
/// Enthält Klassen und Methoden zur Auswertung des Fusion Cache
/// </summary>
public static class Fusion
{
/// <summary>
/// Liefert alle im Global Assembly Cache (GAC) installierte Assemblies.
/// </summary>
/// <returns>Liefert eine generische Liste mit AssemblyName-Objekten.</returns>
public static List<AssemblyName> GetAssembliesFromGAC()
{
List<AssemblyName> assemblyNames = new List<AssemblyName>();
RegistryKey localMaschine = Registry.LocalMachine;
RegistryKey registryKey = localMaschine.OpenSubKey(@"SOFTWARE\Microsoft\Fusion\GACChangeNotification\Default");
foreach (string valueName in registryKey.GetValueNames())
{
if (registryKey.GetValueKind(valueName) == RegistryValueKind.Binary)
{
AssemblyName assemblyName = new AssemblyName(valueName.Split(",".ToCharArray())[0]);
assemblyName.Version = new Version(valueName.Split(",".ToCharArray())[1]);
if (string.IsNullOrEmpty(valueName.Split(",".ToCharArray())[2]) == false)
{
assemblyName.CultureInfo = new System.Globalization.CultureInfo(valueName.Split(",".ToCharArray())[2]);
}
assemblyName.KeyPair = new StrongNameKeyPair(valueName.Split(",".ToCharArray())[3]);
if (valueName.Split(",".ToCharArray()).Length > 4)
{
if (string.IsNullOrEmpty(valueName.Split(",".ToCharArray())[4]))
{
assemblyName.ProcessorArchitecture = ProcessorArchitecture.None;
}
else
{
switch (valueName.Split(",".ToCharArray())[4].ToUpper())
{
case "AMD64":
assemblyName.ProcessorArchitecture = ProcessorArchitecture.Amd64;
break;
case "IA64":
assemblyName.ProcessorArchitecture = ProcessorArchitecture.IA64;
break;
case "MSIL":
assemblyName.ProcessorArchitecture = ProcessorArchitecture.MSIL;
break;
case "X86":
assemblyName.ProcessorArchitecture = ProcessorArchitecture.X86;
break;
}
}
}
assemblyNames.Add(assemblyName);
}
}
return assemblyNames;
}
}
1 Kommentare zum Snippet