.NET Binding Redirection for Compilation
.net, c#
Solution
I doubt it's possible to "fix" it as you want to. If you read documentation for that compile error (https://msdn.microsoft.com/en-us/library/416tef0c.aspx), you will see that you can either update code to use the same version, or reference both versions during compilation (not an option in your case).
Imagine, that version 1.0.0.0 contains method MyMethod(), but version 1.0.0.1 contains MyMethod(string), and first version is used by assembly A, second version is used by assembly you are compiling. How do you want compiler to resolve this? In runtime, when you use binding redirection, only one version of assembly will be loaded still. Here, you do not own code for assembly A (which you are refering to, and which in turn references MyMethod), and reference to assembly 1.0.0.0 is embedded in A's manifest.
Long story short - I suppose only way to solve it for you is use assembly A which references the same version of B as you do.
Problem
I'm getting the following error when I try and compile a utility, which uses files that have been deployed to our client. Assembly '*A* version 2.0.1.2' uses '*B* version 1.1.39.0' which has a higher version than referenced assembly '*B* version 1.1.32.0'. Our client can use these DLLs no problem, because we have a binding redirection config file in place, which takes effect at run-time: ``` <dependentAssembly> <assemblyIdentity name="*B*" publicKeyToken="..." culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.1.32.0" /> </dependentAssembly> ``` To give a bit of background, the DLLs exist in separate solutions, and therefore some of the references are file references rather than project references, just something I have to live with! Is there any equivalent binding redirection that applies at compile time? I've tried compiling using debug DLLs (version 1.0.0.0), with source rolled back to the relevant version above, however I get the following error at run-time: The located assembly's manifest definition does not match the assembly reference Maybe the build server is configured differently to my machine, but anyway that didn't seem to work...