Add Non-GAC reference to project

时间秒杀一切 提交于 2019-12-12 19:39:06

问题


Every time I add a reference to a web project in visual studio 2008 that is in my GAC, it adds the reference as a GAC reference and doesn't copy the file to my bin directory. But for deployment purposes, I would like to add the reference as a non-GAC reference so it adds the dll to my bin directory. I've tried using the browse button to select the reference instead of picking from the list window, but that adds a GAC reference too.

These references all have the .refresh file with them and there is not an option to copy local in the properties of the file.

Any help please?!?


回答1:


Chris, you're probably long past this problem, but I stumbled upon your question when trying to do the same thing in VS 2005. In case anyone else comes here looking for a solution....

You are correct, of course, that a web project does not give you the copy local option on your references that a normal project does, so the Copy Local... solution is a non-starter.

I worked around this problem by simply adding an existing file to my web app's bin directory. The drawback is that it doesn't add the refresh reference, so if you rebuild the external file you'll have to manually refresh the local copy.




回答2:


Right click on the reference, select properties, flip Copy Local from False to True




回答3:


Set it to Copy Local




回答4:


Like someone else mentioned, you're probably long past this problem but I thought I'd throw my solution in the mix.

My problem was a little bit different. I wanted a non-GAC version of a .dll so my build server could compile the project without having the .dll in question installed on that server.

To fix this, I edited the .csproj (.vbproj) file manually (using notepad) and updated the reference file to point to the local version. If this proves troublesome in the future, I'll have to uninstall the project and just use the .dll.

In my case, I changed the line:

<Reference Include="Microsoft.Data.Entity.CTP, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />

to be:

<Reference Include="Microsoft.Data.Entity.CTP, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\Lib\Microsoft.Data.Entity.CTP.dll</HintPath>
</Reference>

where ..\Lib is a directory at the solution level, one directory up from the project file.




回答5:


Another way to accomplish this is just to create the XXX.dll.refresh folders manually and place add them to your bin directory.

I actually create a small helper project to add all the files in my solution\Dependencies folder. Sorry for the VB.NET, but it's quick and appears to do the same thing VS would do.

    For Each fullFileName In Directory.GetFiles("..\..\..\Dependencies\", "*.DLL")
        Dim shortFileName = Path.GetFileName(fullFileName)
        Dim refreshFileName = shortFileName + ".refresh"

        Dim contents = "..\Dependencies\" + shortFileName

        File.WriteAllText(refreshFileName, contents)
    Next



回答6:


1) Remove the GAC reference from your project

2) Close Visual Studio

3) gacutil /uf [YourDllName] (gacutil.exe should be found in "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin")

4) Re-open VS and add reference within the "Browse" tab you will have the dll copied into your bin folder and a .refresh file (no more GAC dependency) +++




回答7:


If you reference .NET Framework standard assemblies, then as I understand you couldn't have a local copy of it. The only way is to install framework on target computer.

It it is a third party assembly then you could copy assembly to bin directory manually from directory where it is located.

You may also try to remove assembly from GAC by gacutil.exe in Windows SDK and look what will happen now if you try to add reference by 'Browse' tab.




回答8:


I spent hours trying to solve this problem and ran across a post saying to open visual studio as administrator. It solved the problem. All referenced dlls were added to the bin folders.



来源:https://stackoverflow.com/questions/387093/add-non-gac-reference-to-project

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