Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

setup project - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;bin2subbin;bin3"/>
      </assemblyBinding>
   </runtime>
</configuration>

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...