How do I add a DLL to GAC

旧城冷巷雨未停 提交于 2019-12-11 08:19:58

问题


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?


回答1:


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.




回答2:


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);
  }



回答3:


You need either to set the working directory of teh process to your current working directory or to send the full path of the .dll



来源:https://stackoverflow.com/questions/18569367/how-do-i-add-a-dll-to-gac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!