VS2015 build error: Cannot add the specified assembly to the global assembly cache

情到浓时终转凉″ 提交于 2019-12-24 15:30:55

问题


I'm trying to deploy GAC into the sharepoint. Deployment fails with this error message:

Error occured in deployment step 'Add Solution': Error: Cannot add the specified assembly to the global assembly cache: Microsoft.Practices.Sharepoint.Common.dll

The problem is that mentioned .dll inside C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Practices.SharePoint.Common\v4.0_2.0.0.0__ef4330804b3c4129\ folder is somehow locked by another .dll called Microsoft.Alm.Shared.Remoting.RemoteContainer.dll.

Only one working solution is restarting windows server, but problem will happen again once I will try to deploy a newer version.

Is there any other solution how to prevent blocking this and other similar dlls?

Thanks


回答1:


The process named Microsoft.Alm.Shared.Remoting.RemoteContainer.dll supplies the feature "CodeLens" in the Visual Studio IDE. This feature supplies some nice functionality in VS like live display of references to functions above their declaration, source control status, test status and some others.

The problem will go away if you disable "CodeLens" in Visual Studio at

Visual Studio Options > Text Editor > All Languages > Code Lens

If you don't want to disable CodeLens all the time on that computer, you can just kill Microsoft.Alm.Shared.Remoting.RemoteContainer.dll before deploying. This will temporarily disable CodeLens in all running instances of Visual Studio, but CodeLens will work again after restarting Visual Studio.

To automate killing the process before trying to register the assembly to the GAC (Global Assembly Cache), add the following command to the same place before your call to gacutil:

taskkill /f /im Microsoft.Alm.Shared.Remoting.RemoteContainer.dll

The actual trigger of the problem is that at least one of your projects in the solution loads the assembly Microsoft.Practices.Sharepoint.Common.dll from the GAC from within the Visual Studio IDE. You can prevent this by having the assembly reference point to a version of Microsoft.Practices.Sharepoint.Common.dll outside the GAC.


The issue was also discussed at Microsoft Connect. Microsoft does not see this a bug and says registering an assembly to the GAC and using assemblies from the GAC during build is not recommended.



来源:https://stackoverflow.com/questions/36336536/vs2015-build-error-cannot-add-the-specified-assembly-to-the-global-assembly-cac

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