在Windows Server 2008和Windows Server 2008 上, 部署程序集到GAC中时,如果以直接将程序集拖拽到GAC的方式部署,将会得到Access is denied的错误消息。
解决方案:
1.关闭UAC,重启服务器,此时重新部署程序集就OK了
此方法有一个缺点,就是修改完UAC后,必须重启服务器。
2.创建一个快捷方式,目标为:%SystemRoot%\explorer.exe C:\Windows\assembly,接着以管理员的身份运行这个快捷方式,此时便可对GAC进行操作。
如果需要部署程序集到GAC中,则使用相同的方式,创建一个快捷方式,目标为:%SystemRoot%\explorer.exe 目标dll文件的路径(如:D:\bin),
此时便可以以直接将程序集拖拽到GAC的方式部署程序集(经测试Windows Server 2008 R2,无法正常工作)。
以下是老外的原文:
Note: 以下方法行不通,
1.Open a Command Prompt as Administrator (right click, Run As Administrator).
2.Run "explorer C:\windows\assembly".
3.Open a new explorer window from the window which just opened (Right click -> Open whilst holding Ctrl). I did this by hopping back up to C:\windows and the navigating to my assembly in the second (new) window.
4.Navigate in the first windows back to C:\windows\assembly.
5.Drag and drop between the two windows.
3. 使用PowerShell 调用 System.EnterpriseServices.Internal.Publish. GacInstall( $assembly )方法。
安装命令: .\Install-GAC.ps1 1 "C:\test.dll"
卸载命令: .\Install-GAC.ps1 0 "C:\test.dll"
详情参考原文:PowerShell: Install-Gac (GACUTIL for PowerShell)