visual-studio Visual Studio 2010“添加引用”正在将 dll 复制到 bin 目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3548731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2010 "Add Reference" is copying dll to bin directory?
提问by David
I am using w7, 64bit and vs.net 2010.
我正在使用 w7、64 位和 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.
我正在添加对“添加引用”对话框中组件的引用。该组件是第 3 方 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.
从历史上看,在 w7 32 位上,它会在我的 web.config(在程序集标记内)中添加一行引用此 dll,并且不会将 dll 复制到 bin 目录。
However, on 64bit w7 the dll is copied to the bin directory and the web.config is not updated at all.
但是,在 64 位 w7 上,dll 被复制到 bin 目录并且 web.config 根本没有更新。
Why is the dll being copied to the bin directory? thanks
为什么要复制dll到bin目录?谢谢
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.
如果您的系统在 GAC 中找不到 dll,VS.NET 会将 dll 复制到 bin 目录。GAC 中的程序集(在您的工作站上注册),可以通过查看 C:\Windows\Assembly 目录找到。
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.
vs.net“添加引用对话框”中列出的组件可能在也可能不在 gac 中。因为组件列在“添加引用”对话框中并不意味着它已在您的本地工作站上注册。我导航到组件目录并将所需的 dll 拖到 C:\Windows\Assembly 目录。我关闭并重新打开 vs.net 并浏览到相同的文件并单击添加引用。
**This added the assembly reference to my web.config (and it also didn't copy the dll to my web site bin directory)****
**这将程序集引用添加到我的 web.config(并且它也没有将 dll 复制到我的网站 bin 目录)****
采纳答案by Russ
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.
它将副本复制到 bin 目录,以便可执行文件可以找到它。否则它不会找到它,除非 dll 安装在 GAC 中。
回答by bdukes
On the reference, there is a Copy Localproperty (in the Properties window), which determines whether the assembly should be copied to the output directory.
在引用上,有一个Copy Local属性(在“属性”窗口中),它确定是否应将程序集复制到输出目录。
As to why that might not have mattered for other references, MSDN says:
至于为什么这对其他参考文献可能无关紧要,MSDN 说:
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 Localsetting.
如果您部署/复制的应用程序包含对在 GAC 中注册的自定义组件的引用,则无论“复制本地”设置如何,该组件都不会随应用程序一起部署/复制。
回答by Julien N
Additionally to previous responses : I think that Visual Studio determines if the Copy Localproperty 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.
除了之前的回复:我认为 Visual Studio 会根据Copy LocalDLL 不在您的计算机 GAC 中这一事实来确定该属性是否设置为 true。
它可以防止 VS 复制本机 .net DLL,因此默认情况下它应该只复制“自定义”DLL。

