Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 "Add Reference" is copying dll to bin directory?

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)****

like image 510
David Avatar asked Aug 23 '10 14:08

David


People also ask

How do I create a reference folder in Visual Studio?

You can also right-click the project node and select Add > Project Reference. If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference.


3 Answers

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.

like image 149
bdukes Avatar answered Sep 22 '22 11:09

bdukes


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.

like image 31
Russ Avatar answered Sep 21 '22 11:09

Russ


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.

like image 25
Julien N Avatar answered Sep 23 '22 11:09

Julien N