Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move all referenced DLLs into seperate folder in c#?

I have a solution with 3 projects in it. 2 of the projects are referencing log4net, and a couple of others DLLs.

When I create the install package and add project output for each of the projects - it drops the DLLs into the main "Application Folder". If I drag these DLLs into a seperate folder I've created in the Setup Project, the applications will not run saying "Cannot find log4net". I want these DLL references in something like "bin" or any name really, just not the main folder they add confusion - I just want my 2 .exe's in the main folder.

I tried adding a reference path in each project to point to the "bin" folder. Then in the setup project, I added an output folder called "bin" and moved the DLLs into that folder, still doesn't work.

What am I missing! I've spent a couple hours looking around trying to figure out what I'm doing wrong, maybe it was the way I was born! Thanks for any help!

like image 758
user53885 Avatar asked Jan 03 '10 21:01

user53885


1 Answers

You can use the <probing> element in the app.config file to specify a private path for Fusion (the assembly loader) to search in.

This allows you to specify paths that are sub-paths of your application directory which Fusion should search when trying to find assemblies to bind to. An example (taken from the documentation page) is:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="bin;bin2\subbin;bin3"/>
      </assemblyBinding>
   </runtime>
</configuration>

This means that Fusion will search in the bin, bin2\subbin (but not bin2, IIRC) and bin3 subdirectories for assemblies when trying to bind to them.

like image 187
casperOne Avatar answered Nov 15 '22 03:11

casperOne