且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C# 将所需的 DLL 放在输出根目录以外的位置

更新时间:2022-11-08 17:44:52

到目前为止的答案令人惊叹.不对;)好吧,

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.