Binding redirects are not generated automatically even with AutoGenerateBindingRedirects
See original GitHub issueThere are two issues here:
- First the
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
is not recognized. The warning message is wrong:
`<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net462</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="7.2.1" />
</ItemGroup>
</Project>`
Produces a warning message saying:
`1>Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "6.0.0.0" [] to Version "9.0.0.0" [C:\Users\me\.nuget\packages\newtonsoft.json\9.0.1\lib\net45\Newtonsoft.Json.dll] to solve conflict and get rid of warning.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the “AutoGenerateBindingRedirects” property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.`
The information in the link says I should enable `AutoGenerateBindingRedirects`, but indeed `<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>` is activated.
- Second: No redirects are created. The assemblies try to access the same wrong version described in the error message.
It looks like the <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
is somehow overlooked.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:29
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Enable or disable autogenerated binding redirects
Right-click the project in Solution Explorer and select Properties. · On the Application page, uncheck the Auto-generate binding redirects option ...
Read more >Why doesn't AutogenerateBindingRedirects work for a Web ...
Inspecting the output from the build shows that binding redirects are generated just not in the Web.config. Instead, they are in ...
Read more >Automatically generating assembly binding redirects
Automatically generating assembly binding redirects .NET has a weird way of referencing dependencies. When one "assembly" (EXE or DLL) ...
Read more >Binding Redirects
The fix if you're using .NET Framework · Enable <AutoGenerateBindingRedirects> (this doesn't work for web projects - it doesn't handle web.config ).
Read more >Auto-Generate Binding Redirects is not available - YouTrack
I have standard Web Forms Web application and feature is not available. Why? It should be available for all full .Net framework apps,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nguerrera Yes, after my last message I was trying new solutions and the one proposed in here worked for me. So, none of the other solutions had any effect. The only thing that created the redirects was adding the target:
Without that the error will happen whenever I run the build in Windows. It happens both if the conflict is in a dependent dll or in the .exe (no difference at all).
I had this problem and will add my own experience. First off, I ended up turning on
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType
for all projects, both libraries and executables. I don’t know why this is not the default as this fixed dozens of projects by itself!I still had a project that generated this mysterious error, even though it was definitely generating the *.dll.config file with all of the correct bindingRedirects. In my case, the problem was caused by a PackageReference that transitively pulls in Microsoft.Bcl.Build. This invisibly changed properties and added targets to the build. Once I turned up the build log verbosity to “Detailed” I found this:
Then later, while building target
ResolveAssemblyReferences
I confirmed:… right before the string of errors.
I have no idea what this property is for, because the bindingRedirects were still created, so whether it liked it or not, the assembly references were unified anyway. I was able to fix the error by adding to my project file:
Hopefully this will save time for others, as I was struggling with this for quite a while.