开发者

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 referenc开发者_JAVA技巧e 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!


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.


I wrote a nuget package, called PrettyBin for this purpose It addes a post build target to a project, that moves dlls to a "lib" subfolder, and modifies app.config to look there

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜