I\'ve got a VS2017 project that compiles to a DLL which is then called by an EXE written by someone else. Both projects target .Net Framework 4.6.2. I rewrote one of my DLL
ok this feels completely wrong but I cut
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ffffd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
This out of my web.config for the main application.
I was really just seeing what happened to see if there was an underlying dependency or something, not expecting it to run. It just carried on working, all the new functions I have added in the last few days still work.
I faced the same exception when there was a nuget package version mismatch. (In the DLL was 4.3.1 used while in the main program 4.3.0.) I have resolved the issue by upgrading the packages to the same version... Checking and unifying the package versions could hopefully help you as well.
I had this same issue with an AutoMapper 8.0.0.0 dependency on version 4.5 after upgrading from .NET 4.5.1 to 4.6.1. Reinstalling the automapper nuget package worked for me.
FWIW, I had this issue on my testing project using Moq. Someone had set the project to .NET 4.7, but I was on 4.6.2. Not wanting to move to 4.7 yet, the solution was to downgrade the version to Moq 4.7.145. The System.ValueTuple v 4.3.1 worked together with it.
In my solution I found 2 different trouble maker. Either in the App.config or Web.config file:
Version mismatch: The version installed via NuGet did not match the version in the config file. Solution: Change the version manually in the .config file.
Duplicate entries: I found duplicate entries for ValueTuple. In my case one for 4.0.3.0 and another one for 4.5.0. Removing the older entry solved the issue.
In another case I managed to fix the issue by removing unneeded references and getting rid of the ValueTuple NuGet package altogether.
Adding on to Robin's answer for just changing the Web.config. I was able to get away with only commenting out the binding redirect tag.
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ffffd51" culture="neutral" />
<!--<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />-->
</dependentAssembly>
This got rid of the error for me.