With today’s release of the RTM versions of Win8 and Visual Studio 2012 I, like many others no doubt, have formatted one of my machines, thrown the new bits on, and kicked the tyres with some code. Unfortunately, when I tried Nancy, everything build just fine, but running any tests involving NDjango (F# based) blew up with:
Could not load file or assembly ‘FSharp.Core, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly ‘FSharp.Core, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.
All this works perfectly fine with .net 4, and .net 4.5 is supposed to be backwards compatible, but in this case it seems not. I haven’t done much digging, but if a strongly named assembly changes version between .net 4 and .net 4.5 I would expect an assembly binding to be in place to stop this kind of thing from happening – it’s possible that NDjango is doing something odd, but still, if it works in 4, it should work in 4.5.
This may or may not be an issue on Win7 if you’ve had .net 4 installed previously.
Luckily, it’s very simple to add your own binding redirects to get things up and running again. These can either go in the app.config/web.config of your application, or you can put it in the machine.config – I wouldn’t recommend the latter though, as you may end up with an “it works on my machine” situation a few months down the line.
Either way, this is the section you need to add, it maps both 22.214.171.124 and 126.96.36.199 to the version that ships with .net 4.5/Win8 :
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="188.8.131.52" newVersion="184.108.40.206"/> <bindingRedirect oldVersion="220.127.116.11" newVersion="18.104.22.168"/> </dependentAssembly> </assemblyBinding>
A simple solution, and maybe this will just affect me, but this blog post will at least stop me from pulling my own hair out if this happens againShare:
"This post was aggregated from http://www.grumpydev.com/2012/08/16/could-not-load-file-or-assembly-fsharp-core-with-net-4-5-ndjango-win8/ and all comments should be submitted on the original post"