Recently I came across this problem with one my console applications while working with ADAL library. After debugging for a while, came to know that this DLL referenced had been updated and I strangely note that error popping up.
Then I came to know that there was an assembly binding defined with a different version from the DLL present in the bin folder. So I tried to understand a bit about assembly binding and what assembly binding redirect is all about.
Why are binding redirects needed at all?
Suppose you have application A that references library B, and also library C of version 220.127.116.11. Library B in turn also references library C, but of version 18.104.22.168. Now we have a conflict, because you cannot load different versions of the same assembly at runtime. To resolve this conflict you might use binding redirect, usually to the new version (but can be to the old too). You can do that by adding the following to app.config file of application A, under
configuration>runtime>assemblyBinding section (see here for an example of full config file):
<dependentAssembly> <assemblyIdentity name="C" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" /> <bindingRedirect oldVersion="22.214.171.124" newVersion="126.96.36.199" /> </dependentAssembly>
You can also specify a range of versions to map:
<bindingRedirect oldVersion="0.0.0.0-188.8.131.52" newVersion="184.108.40.206" />
Now library B, which was compiled with reference to C of version 220.127.116.11 will use C of version 18.104.22.168 at runtime. Of course, you better ensure that library C is backwards compatible or this might lead to unexpected results.
You can redirect any versions of libraries, not just major ones.
If you want to know more about assembly binding, redirects. Please refer to below post.
Finally I was able to resolve this issue by commenting this section in App.config. The fix seem to be easy.
Hope this helps.