C# Putting the required DLLs somewhere other than the root of the output(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>
根据:
http://msdn.microsoft.com/en-us/library/823z9h8w.aspx
这将使程序查找程序集的私有路径(它自己的文件夹下的文件夹) - 就像 Web 应用程序查找/bin.
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 多个程序集的项目.用户根本看不到他们.
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 放在输出根目录以外的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# 将所需的 DLL 放在输出根目录以外的位置
基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30