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

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

问题描述

使用NuGet为具有多个dll和仅一个exe(使用所有其他dll)的解决方案安装Microsoft.Bcl.Async软件包,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软件包更新过程中,带有assemblyBinding的app.config与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天全站免登陆