是否需要 bindingRedirect .config 文件或应用程序中的所有程序集? [英] Is the bindingRedirect .config file needed or all assemblies in an application?

查看:19
本文介绍了是否需要 bindingRedirect .config 文件或应用程序中的所有程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 NuGet 为一个解决方案安装 Microsoft.Bcl.Async 包,该解决方案有多个 dll 和一个 exe,它使用所有其他 dll,NuGet 会自动为每个文件创建一个 .config 文件(或添加到现有文件)将 Bcl 包添加到的项目.

Using NuGet to install the Microsoft.Bcl.Async package for a solution that has several dlls and just one exe, which uses all other dlls, NuGet automatically creates a .config file (or adds to an existing one) for every single project the Bcl package is added to.

实际上,我最终得到了 > 20 个包含相同重定向的配置文件.我了解重定向 是必需的,但是鉴于所有程序集都由单个应用程序加载(如果重要的话,其中一些由 Prism 加载),所有程序集实际上都需要这样做吗?我从输出目录中删除了所有 .config 文件,只留下 app.config 并且应用程序似乎工作得很好.我的假设是否正确,一旦 bindingRedirect 在启动应用程序时生效,加载到该域中的所有其他程序集也会自动使用重定向?或者有什么注意事项?我问的主要原因是要知道在重新分发应用程序时是否应包含所有这些配置文件.

In practice I end up with > 20 config files all containing the same redirects. I understand the redirect is needed, but is this actually required for all assemblies given they are all loaded by a single application (some of them by Prism if that matters)? I removed all .config files from the output directory, leaving just app.config and the application seems to work just fine. Is my assumption correct that once the bindingRedirect took effect upon starting the application, all other assemblies that are loaded into that domain also automatically use the redirect? Or are there any caveats? Main reason I'm asking is to know if all these config files should be included upon redistributing the application.

推荐答案

可以参考这个问题:

为什么添加 NuGet在 NuGet 包更新期间 app.config 与 assemblyBinding 到 LIBRARY 项目?

我认为上述问题的答案足以回答您的疑问.

I think the answer to the above question amply answers your query.

不过,如果您想要摘要,您实际上是对的.在单个应用程序中您只需要一个 .config 文件.当您只使用/引用相应的程序集时,每个程序集的 .config 文件用于测试.因此,如果您要部署应用程序,则不需要每个程序集的 .config 文件.应用程序范围的 .config 文件就足够了.

Still, if you want the summary, you are actually right. You just need one .config file in a single application. Per-assembly .config files are used in tests when you only are using/referencing the respective assembly. So, if you are deploying the application, you do not need the per-assembly .config files. The application wide .config file would suffice.

这篇关于是否需要 bindingRedirect .config 文件或应用程序中的所有程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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