问题
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