Is the bindingRedirect .config file needed or all assemblies in an application? [duplicate]

青春壹個敷衍的年華 提交于 2019-12-19 10:26:22

问题


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.

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.


回答1:


You can refer to this question:

Why NuGet adds app.config with assemblyBinding to LIBRARY projects during a NuGet package update?

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

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.



来源:https://stackoverflow.com/questions/21795507/is-the-bindingredirect-config-file-needed-or-all-assemblies-in-an-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!