在 C#/.NET 中设置依赖项的文件夹
我有一个带有大量依赖项的 C# 项目,但我想将它们存储在可执行文件所在的另一个文件夹中。
例如
WTEngine/
/bin
--Dependencies go here
/otherfolder
WTEngine.exe
我该怎么做?我移动了它们,可执行文件再也找不到它们了
I have a C# project with a bunch of dependencies, but I want to store them in another folder from where the executable is.
For example
WTEngine/
/bin
--Dependencies go here
/otherfolder
WTEngine.exe
How do I do that? I move them and the executable can't find them anymore
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ASP.NET 的这个答案解决了同样的问题,并且大多数答案都可以有效地移植到桌面可执行文件:如何在 ASP.net 应用程序中引用 bin 文件夹之外的程序集?
另请参阅 如何更改在托管 C++ 中通过 #using 引用的 .NET 库的查找路径?
This answer for ASP.NET addresses the same issue, and most of the answers can be effectively ported to a desktop executable: How do I reference assemblies outside the bin folder in an ASP.net application?
Also see How do I change the lookup path for .NET libraries referenced via #using in Managed C++?
.NET 依赖项会从两个位置自动加载:
您无法将依赖项移动到另一个文件夹中并自动加载它们。
如果您决定手动加载程序集,请查看以下问题:
如何递归地将程序集加载到 AppDomain 并包含所有引用?
The .NET dependencies are loaded automatically from two places:
You cannot move the dependencies in another folder and have them loaded automatically.
If you decide to load the assemblies manually, check out this question:
How to Load an Assembly to AppDomain with all references recursively?