C#把所需的DLL某处以外的输出的根 [英] C# Putting the required DLLs somewhere other than the root of the output

查看:130
本文介绍了C#把所需的DLL某处以外的输出的根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用EmguCV的一个项目,我们的程序运行时,它需要某​​些DLL像cxcore.dll等(或它抛出运行时异常)。此刻,我把文件输出文件夹(在Visual Studio中的文件的属性中选择复制总是)的根。

I am using EmguCV for a project and when our program runs it needs some dlls like "cxcore.dll" etc. (or it throws runtime exceptions). At the moment, I put the files in the root of the output folder (selected "Copy Always" in the file's properties in Visual Studio).

然而,它看起来有点凌乱,有大约10不同的dll就在那里。有什么方法,我可以把它移动到输出文件夹的子文件夹,它还是会找到它。

However it looks a bit messy, to have about 10 different dlls just there. Is there someway where I can move it to a subfolder in the output folder and it'll still find it.

推荐答案

惊人的答案为止。无权利;)好了,

Amazing answers so far. None right ;) Well,

是的,你可以把组件在不同的地点。

yes, you can put the assemblies in separate locations.

在相应的应用程​​序配置(的app.config 这被复制到 your.exe.config )地址:

In the corresponding application config (app.config which gets copied to your.exe.config) add:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="lib" />
    </assemblyBinding>
  </runtime>

<一个href=\"http://msdn.microsoft.com/en-us/library/823z9h8w.aspx\">http://msdn.microsoft.com/en-us/library/823z9h8w.aspx

这将使程序看看私人路径(在它自己的文件夹,文件夹)组件 - 就像一个Web应用程序查找/斌

This will make the program look into the private path (folders under it's own folder) for assemblies - much like a web application looks for /bin.

您也可以把它们放进GAC,但应尽量避免,除非有其他原因。

You can also put them into the GAC, but that should be avoided unless there are other reasons for this.

话虽这么说,你真的不需要。如果你在开始菜单中正确安装应用程序的用户不会混淆;)我从来没有过这样的问题,其中包括50 +组件项目。用户simlpy再也看不到他们。

That being said, you really dont need to. Users wont get confused if you install the application properly in the start menu ;) I never had that problem, including projects with 50+ assemblies. Users simlpy never see them.

这篇关于C#把所需的DLL某处以外的输出的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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