views:

32

answers:

2

I'm working through installing the N2 content management framework in an ASP.NET website project.

The instructions at http://n2cms.com/Documentation/Content-enabling%20an%20existing%20site/The%20first%20content%20class.aspx recommend I create a lib folder to hold the required dlls. The very next step asks me to reference those same dlls - which will presumably add them to the bin folder! Thus my project will contain duplication copies of the dlls.

Can anyone suggest why this recommendation has been made?

Thanks

David

+1  A: 

The project will not contain duplicates. The bin folder is where the output goes, but it is not considered part of your actual project and is not checked into source control.

By placing the DLLs in a lib folder, it makes it easier to distribute them with the source of your application and ensures that anyone else who gets a copy of your code, whether you send it to them or they grab it from source control, has the necessary DLLs to run the application. It also ensures that they are use the same version of the components that you used to create the software. If the DLLs require licensing, it can be a different story because anyone who wants to compile the project would need the licensing component for the DLLs installed on their workstation.

Basically, the main benefit I see is that it keeps all components used by your code in the same place, making your project one whole unit.

NYSystemsAnalyst
So, if you add the dll to a folder in your project, then reference it, it's not copied into bin?
David
It is still copied to Bin. However, when you commit your code to source control or distribute it to someone else, you normally do not include the bin folder. The Bin folder is an output folder. Although items end up in the bin folder when the project is compiled, you should not reference anything directly from the bin folder because it is volatile and constantly being overwritten by the VS compiler.
NYSystemsAnalyst
Okay, I understand, thanks.
David
A: 

If you add the DLLs to the bin folder, then one day decide to clean your project, they will disappear... So it's good practice to keep your reference DLLs out of the bin folder.

Actually there's quite a few ways the DLLs can be accidentally removed from the bin folder. Just think of the bin folder as a transient location, the contents of which can be refreshed at a moment's notice.

During the build process all relevant files will be copied to the bin folder, including config files, content files marked for copy to the output folder, and of course, any referenced DLLs marked for Copy Local.

If the duplicate locations bother you, you can keep the DLLs in another folder, and just add the containing folder path to the PrivateBinPath of the current AppDomain, which will ensure they get loaded without requiring the Copy Local property.

code4life