Visual Studio 2010 “Add Reference” is copying dll

2019-06-17 04:48发布

I am using w7, 64bit and vs.net 2010.

I am adding a reference to a component that is within my 'add references' dialog box. The component is a 3rd party dll.

Historically, on w7 32bit it would add a line in my web.config (within the assemblies tag) referencing this dll and it wouldn't copy the dll to the bin directory.

However, on 64bit w7 the dll is copied to the bin directory and the web.config is not updated at all.

Why is the dll being copied to the bin directory? thanks

Solution: (Updated) These posts gave me the clues I needed.

VS.NET will copy the dll to the bin directory if your system cannot find the dll in the GAC. Assemblies in the GAC (registered on your workstation) and can be found by looking at C:\Windows\Assembly directory.

Components listed in vs.net ‘add references dialog’ may or may not be in the gac. Because the component is listed in the ‘add references’ dialog doesn't imply it is registered on your local workstation. I navigated to the component directory and dragged the desired dll’s to the C:\Windows\Assembly directory. I closed and re-opened vs.net and browsed to the same file(s) and clicked add reference.

**This added the assembly reference to my web.config (and it also didn’t copy the dll to my web site bin directory)****

3条回答
放我归山
2楼-- · 2019-06-17 05:27

It gets copies to the bin directory so that the executable can find it. It won't find it otherwise, unless the dll is installed in the GAC.

查看更多
迷人小祖宗
3楼-- · 2019-06-17 05:41

Additionally to previous responses : I think that Visual Studio determines if the Copy Local property is set to true based on the fact that the DLL is not in your computer GAC.
It prevents the VS to copy the native .net DLLs, so it should by default only copy "custom" DLLs.

查看更多
Explosion°爆炸
4楼-- · 2019-06-17 05:51

On the reference, there is a Copy Local property (in the Properties window), which determines whether the assembly should be copied to the output directory.

As to why that might not have mattered for other references, MSDN says:

If you deploy/copy an application that contains a reference to a custom component that is registered in the GAC, the component will not be deployed/copied with the application, regardless of the Copy Local setting.

查看更多
登录 后发表回答