C# – How to add a DLL to GAC

cglobal-assembly-cachenet

This is my code:

Register(Assembly.GetExecutingAssembly()).Location);

private void Register(String assemblyName)
{
    System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo("D://gacutil.exe", string.Format("/i {0}", assemblyName));
    processStartInfo.UseShellExecute = false;
    System.Diagnostics.Process process= System.Diagnostics.Process.Start(processStartInfo);
    process.WaitForExit();
}

How do I add the DLL to the assembly Folder?

Best Answer

You have to put the entire assembly path for this to work. For example

gacutil /i D:/someassembly

Rest of your code looks fine. Just use whole assembly path instead of just assembly name.