Using reference libraries (dll) stored in a differ

2019-07-18 04:02发布

问题:

(This might be a obvious question but I wasn't sure what to ask Bing/Google)

In a VS2008 (C# Winforms) project there are numerous third party libraries that are referenced. The project uses 'Copy Local = True' so that the various DLL files end up in the same folder as the compiled application.

To clean things up I would like to modify the program so that the libraries are all under a subfolder.

For example:

C:\MyProgram\ -> main program folder C:\MyProgram\Libraries -> DLL storage folder

How would I do this?

回答1:

The best way to do this is to add an app.config file to your solution and setup private probing paths for each of the sub folders. The CLR will then look in these folders when searching for assemblies

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="subFolder1;subFolder2;" />
      </assemblyBinding>
   </runtime>
</configuration>

Documentation

  • http://msdn.microsoft.com/en-us/library/823z9h8w(VS.80).aspx