Assembly binding added in compiled output (app.config)

我怕爱的太早我们不能终老 提交于 2021-01-28 07:31:38

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/64555429/assembly-binding-added-in-compiled-output-app-config

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