使用存储在与主程序不同的文件夹中的参考库(dll)? [英] Using reference libraries (dll) stored in a different folder from the main program?

查看:137
本文介绍了使用存储在与主程序不同的文件夹中的参考库(dll)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(这可能是一个很明显的问题,但我不确定要问Bing/Google)

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

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

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.

例如:

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

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

我该怎么做?

推荐答案

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

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>

文档

这篇关于使用存储在与主程序不同的文件夹中的参考库(dll)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆