Question

Supposed that i have several projects in vs2010, one named app, which is the main project.When i refrence a dll in another class libary project that the app project uses and i make sure the refrenced dll has been copied to the bin folder of the class libary project, but there is a runtime error reminding me that the refrenced dll can not be found unless i place the dll to the main project's bin folder. Why is that? Looking forward to your answer, thanks!

Was it helpful?

Solution

There is a .dll search order. refer to http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

OTHER TIPS

I tried to search "why referenced dll is copied in bin folder" but was not able to find any specific post or blog but isnt this the correct way of building an application? .net makes sure that all dlls from other referred projects are copied to the bin folder of the executable so that there is no machine level dependency. This is true provided your project dlls are referenced locally. If you want your project dlls to be referenced by multiple projects then, either distribute those dlls or you would need to put those dlls in the global assembly cache (GAC) of the machines where these dlls are being distributed. To do this the link is here.

Also you do not need to copy and paste each referenced dlls into the bin folder. .net does that automatically. If it is not in your case then right click on the child project in the References area, go to properties, and set "Copy Local" to True.This will copy the dll into your output/bin folder for distribution and should solve the dependency on a machine without the DLL.

I hope this was of some help.

Regards,

Samar

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top