简体   繁体   中英

How do I add a DLL to GAC

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?

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.

MSDN Publish.GacInstall

Use GacInstall() method in the Publish class to GAC the assembly easily. Add reference to System.EnterpriseServices . Please make sure particular dll is Signed . Only signed assembly can be added to GAC.

private void Register(String assemblyName)
  {
      Publish publish = new Publish();
      publish.GacInstall(assemblyName);
  }

您需要将process的工作目录设置为当前工作目录,或者发送.dll的完整路径。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM