Reference DLL file not copying to bin with deploym

2019-01-12 20:39发布

We have several external DLL files being referenced in our Web Application Project. We have a deployment project for installing on the hosting servers. When we were using .NET 3.5 and Visual Studio 2008 the DLL file were being copied to the bin folder. Since we have upgraded to .NET 4 and Visual Studio 2010 this no longer happens, and we are getting servers errors since the references cannot be found.

CopyLocal is set to true, and I cannot find anything inside the web.config which suggest this is being set elsewhere.

13条回答
Root(大扎)
2楼-- · 2019-01-12 20:50

We can use the <Private>False</Private> to not to copy the referenced DLL files to the bin directory. This is useful when we are building applications in a separate TFS build server where we need to build the application and not to copy the DLL files to the bin directory.

查看更多
Lonely孤独者°
3楼-- · 2019-01-12 20:52

If your project does not directly load the library, it won't always be deployed, even if it is referenced explicitly! I got confused because I could see it in a local Bin directory but not when deployed. The dll in the Bin directory was an old file that wasn't removed during Clean which is why I was confused.

A full clean and rebuild and it wasn't in my local Bin folder either which showed me the problem (I only use it in web.config). I then referenced the dll file itself in the project and set it to copy to output to make sure it gets deployed.

查看更多
我只想做你的唯一
4楼-- · 2019-01-12 20:53

I didn't meet the same problem but similar. I had WPF main project and referenced project where the referenced did not copy. I found that in my case the main project was set for NET 4.0 Client Profile and the referenced for NET 3.5. When I set the main project to 3.5 the compiled dll of the referenced project started to copy. (I don't know why because I solved it by practice)

查看更多
倾城 Initia
5楼-- · 2019-01-12 20:58

I had a similar issue with VS 2012 Express. I used Tesseract libraries in my project. Everything worked well until I used this project in a solution where were more than one project. Problem was that some DLLs (liblept168.dll, libtesseract302.dll) that are normally placed in folders bin/debug/x86 or bin/debug/x64 were copied only when I rebuilt whole solution. Changing a single line and building it again caused that the DLLs were deleted and not copied back.

I solved this issue by adding a reference of the project that creates missing DLLs to the startup project.

查看更多
我想做一个坏孩纸
6楼-- · 2019-01-12 20:59

I just had the same issue and wanted to share what I found as it might help someone:

The reason in my case was that the assembly was installed in the GAC during an installation of some third-party application.

If the DLL file is in the GAC, the compiler won't bother to copy it to the destination folder, unless you specifically mark it for "copy local" using the "Private" node in the project file as mentioned by Junto.

The thing is that if you don't add that node, and you develop on one machine and build on a different one, and the DLL file is only in the GAC of the build machine, the default behavior without the private node will cause the file to be copied correctly on the development machine, but not on the build machine.

The bigger problem is if the DLL file is not referenced directly, but the project references a second project that in turn references the DLL file. In that case, you cannot mark the DLL file to be "copy local" in the project, as it is not referenced by it. So if the DLL file exists in the GAC - it won't get copied to your output folder.

Possible solutions to this case are:

  • Uninstall the DLL file from the GAC
  • Add a direct reference to the DLL file in the end project(s)
  • Re-sign the DLL file with a new strong name, which will differentiate it from the DLL file in the GAC.
查看更多
够拽才男人
7楼-- · 2019-01-12 20:59

I too ran into a similar issue where referenced dlls were not copied into the bin in published folder. I was using a TFS checked out copy that didn't include the bin folder into the application. -> So just included the bin folder. -> Built the referenced applications -> Published the website project Now I see all the referenced dlls in bin in the published folder

查看更多
登录 后发表回答