Adicionando e removendo um assembly do GAC:
internal static class GAC
{
/// <summary>
/// Add strong-named assembly to GAC. DLL must be in current directory.
/// </summary>
/// <param name="assemblyName">name of assembly (without .dll extension).</param>
internal void Register ( String assemblyName )
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("gacutil.exe", string.Format("/i {0}.dll", assemblyName));
processStartInfo.UseShellExecute = false;
Process process = Process.Start(processStartInfo);
process.WaitForExit;
}
/// <summary>
/// Remove assembly from GAC.
/// </summary>
/// <param name="assemblyName">name of assembly (without .dll extension).</param>
internal void Unregister ( String assemblyName )
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("gacutil.exe", string.Format("/u {0}.dll", assemblyName));
processStartInfo.UseShellExecute = false;
Process process = Process.Start(processStartInfo);
process.WaitForExit;
}
}
Obs: GACUTIL deve ter permissão de administrador.
Fonte: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7d3165cf-ca3b-43cc-8f77-a46dbf38f13d/#a34173da-e511-4e56-a452-11afd827269c
Nenhum comentário:
Postar um comentário