Using reference libraries (dll) stored in a differ

2019-07-18 04:00发布

(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条回答
时光不老,我们不散
2楼-- · 2019-07-18 04:12

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

查看更多
登录 后发表回答