Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET and Visual Studio - Adding project references vs Bin Folder DLL

I just started a new job yesterday and this is only my second job working in ASP.NET. We were setting up my dev box and were having trouble with some third party components like Telerik, etc. I was noticing that they were installed these third party tools, hunting down the DLL files, copying them into the bin and then adding a reference to the project which points to the file in the BIN. To me, this doesn't seem like normal practice.

I was under the impression that if you just dump a DLL in the bin folder, you don't need to add a reference, it's just available? Reason being, at my last job we used a few class libraries we built in house for data access and just dropped the DLLs in any new websites (not webapps) that we made. I don't recall every having to add a reference to get it to work.

So, can someone explain best practices on how to add third party references to your web app? Do you add the reference from wherever the DLL is installed in the system? If so, do you check copy local so it copies to the bin? Do you just copy the dll to the bin and that's it? Do you copy the dll to the bin and then add a reference to it there?

Sorry, I'm sure this seems like a simple question, but I'm confused by the two seemingly different methods I've seen used.

like image 402
WesleyJohnson Avatar asked Nov 11 '09 00:11

WesleyJohnson


1 Answers

It depends on how your project is set up. If you want to precompile your site (and get Intellisense to work properly) you have to have a Visual Studio reference. But anything dropped in the bin folder will be automatically loaded by ASP.NET at runtime... so it's possible to access that assembly's controls/objects in code behind without adding a project reference.

For small projects I just throw the DLL into the bin and add reference. For more complex sites/projects, I have a dedicated "library" folder for third party add-ons and code.

like image 66
Bryan Avatar answered Sep 30 '22 04:09

Bryan