在编译输出中添加的程序集绑定 (app.config) [英] Assembly binding added in compiled output (app.config)

查看:84
本文介绍了在编译输出中添加的程序集绑定 (app.config)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我编译我的应用程序,会在输出中自动添加一个程序集绑定.特定的程序集绑定不在 Visual Studio 的 app.config 中,而是在创建的应用程序配置中.

有什么办法可以检查为什么会自动添加程序集绑定?选项 AutoGenerateBindingRedirects 未启用.

我不想有以下程序集绑定

这很奇怪,因为我们在4.7.3

目录下有4.0.2.2版本

非常感谢!

解决方案

实际上BindingRedirectpackages.config nuget 的特性管理格式,它仍然有一些缺点.

<块引用>

有什么办法,检查一下为什么要添加程序集绑定自动地?选项 AutoGenerateBindingRedirects 未启用.

此行为由 nuget 包本身和 packages.config nuget 管理格式控制.由于您的代码使用来自不同版本程序集的部件,并且 packages.config 管理格式无法自动切换它们.

所以 BindingRedirect 出现了.到目前为止,一些nuget包已经通过packages.config添加了这个功能,当你通过packages.config安装这个nuget包时,它会自动添加BindingRedirect 并且不受我们控制.

为了放弃BindingRedirect和所有这些复杂的问题,我建议你可以使用新的

5) 重新启动您的项目,然后再次构建以进行测试.

If I compile my application, an assembly binding is added automatically in the output. The specific assembly binding is not in the app.config in Visual Studio but in the created application config.

Is there any way, to check why the assembly binding is added automatically? The option AutoGenerateBindingRedirects is not enabled.

I don't want to have the following assembly binding

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.2.2" newVersion="4.0.2.2" />
  </dependentAssembly>
</assemblyBinding>

Furthermore, a completly differnt assembly version is installed.

EDIT

When looking into the compiler binlog result (compiled with msbuild /bl) this occurs:

This is pretty strange, because we've got the version 4.0.2.2 in the directory of 4.7.3

Thanks you very much!

解决方案

Actually, BindingRedirect is the feature of the packages.config nuget management format and it still have a bit drawbacks.

Is there any way, to check why the assembly binding is added automatically? The option AutoGenerateBindingRedirects is not enabled.

This behavior is controlled by the nuget package itself and the packages.config nuget management format. Since your code uses the part from different versions of the assembly and packages.config management format does not have the ability to switch them automatically.

So BindingRedirect comes up. And so far, some nuget packages have added this feature with packages.config and when you install this nuget package by packages.config, it will automatically add the BindingRedirect and it is not controlled by us.

In order to abandon the BindingRedirect and all these complex issues, I suggest you could use the new PackageReference nuget management format. And it is a better one which has solved the BindingRedirect issue and optimized package management. And in this one, you do have to use BindingRedirect.

Suggestion

1) Right-click on the packages.config file--> click Migrate packages.config to PackageReference.

2) then delete any bindredirect on the app.config file.

3) delete any AutoGenerateBindingRedirects in your xxx.csproj file if you have.

4) close VS, delete .vs hidden folder under the solution folder, any bin and obj output folders.

5) restart your project and then build again to test it.

这篇关于在编译输出中添加的程序集绑定 (app.config)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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