如何将所有引用的 DLL 移动到 C# 中的单独文件夹中?
我有一个包含 3 个项目的解决方案。其中 2 个项目引用了 log4net 和其他几个 DLL。
当我创建安装包并为每个项目添加项目输出时,它将 DLL 放入主“应用程序文件夹”中。如果我将这些 DLL 拖到我在安装项目中创建的单独文件夹中,应用程序将不会运行并显示“找不到 log4net”。我希望这些 DLL 引用位于“bin”或任何名称之类的名称中,而不是主文件夹中,它们会增加混乱 - 我只希望我的 2 .exe 位于主文件夹中。
我尝试在每个项目中添加引用路径以指向“bin”文件夹。然后在安装项目中,我添加了一个名为“bin”的输出文件夹,并将 DLL 移动到该文件夹中,但仍然不起作用。
我还缺什么啊!我花了几个小时环顾四周,试图找出我做错了什么,也许这就是我生来的方式!感谢您的帮助!
I have a solution with 3 projects in it. 2 of the projects are referencing log4net, and a couple of others DLLs.
When I create the install package and add project output for each of the projects - it drops the DLLs into the main "Application Folder". If I drag these DLLs into a seperate folder I've created in the Setup Project, the applications will not run saying "Cannot find log4net". I want these DLL references in something like "bin" or any name really, just not the main folder they add confusion - I just want my 2 .exe's in the main folder.
I tried adding a reference path in each project to point to the "bin" folder. Then in the setup project, I added an output folder called "bin" and moved the DLLs into that folder, still doesn't work.
What am I missing! I've spent a couple hours looking around trying to figure out what I'm doing wrong, maybe it was the way I was born! Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
元素 在 app.config 文件中指定 Fusion(程序集加载器)要搜索的私有路径。这允许您指定应用程序目录的子路径,Fusion 在尝试查找要绑定的程序集时应搜索该路径。一个示例(取自文档页面)是:
这意味着 Fusion 在尝试绑定到程序集时将在 bin、bin2\subbin(但不是 bin2、IIRC)和 bin3 子目录中搜索程序集。
You can use the
<probing>
element in the app.config file to specify a private path for Fusion (the assembly loader) to search in.This allows you to specify paths that are sub-paths of your application directory which Fusion should search when trying to find assemblies to bind to. An example (taken from the documentation page) is:
This means that Fusion will search in the bin, bin2\subbin (but not bin2, IIRC) and bin3 subdirectories for assemblies when trying to bind to them.
为此,我编写了一个名为 PrettyBin 的 nuget 包
它将构建后目标添加到项目中,将 dll 移动到“lib”子文件夹,并修改 app.config 以查看那里
I wrote a nuget package, called PrettyBin for this purpose
It addes a post build target to a project, that moves dlls to a "lib" subfolder, and modifies app.config to look there