使用存储在主程序不同文件夹中的参考库(dll)?

Joh*_*n M 2 c# external shared-libraries visual-studio-2008

(这可能是一个显而易见的问题,但我不确定要问什么Bing/Google)

在VS2008(C#Winforms)项目中,引用了许多第三方库.该项目使用"Copy Local = True",以便各种DLL文件最终与编译的应用程序位于同一文件夹中.

为了清理我想修改程序,以便库都在子文件夹下.

例如:

C:\ MyProgram\ - >主程序文件夹C:\ MyProgram\Libraries - > DLL存储文件夹

我该怎么做?

Jar*_*Par 6

执行此操作的最佳方法是将app.config文件添加到解决方案中,并为每个子文件夹设置私有探测路径.然后,CLR将在搜索程序集时查看这些文件夹

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="subFolder1;subFolder2;" />
      </assemblyBinding>
   </runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)

文档