base CLI library 'mscorlib' is binary-inco

2019-06-21 23:39发布

问题:

I've built a website that takes code snippets and compiles them and runs them. However, F# is broken on the server. Whenever I try to compile F# code I get the following error message:

The referenced or default base CLI library 'mscorlib' is binary-incompatible with the referenced F# core library 'C:\Program Files (x86)\Microsoft F#\v4.0\FSharp.Core.dll'. Consider recompiling the library or making an explicit reference to a version of this library that matches the CLI version you are using.

Error opening binary file 'C:\Program Files (x86)\Microsoft F#\v4.0\FSharp.Core.dll': Exception of type 'Microsoft.FSharp.Compiler.ErrorLogger+ReportedError' was thrown.

To be clear, this is an error being returned by the compiler, not an error that occurs when the code is run.

The site runs just fine on my development machine and works just fine on a VM I spun up to help diagnose the issue.

The only Google hit for the error message caused me to try cleaning up the F#/.NET install to no avail. I did a repair install of the framework and uninstalled/reinstalled the F# packages I'm using.

Example: http://dotnetpad.net/ViewPaste/ZvXBgizf70q83Fk6VmboHw

F# compilation code: http://bitbucket.org/gobiner/.net-pad/src/tip/DotNetPad/Compilers/FSharpCompiler.cs

回答1:

What is the command-line you are passing to fsc.exe on the server? It smells like you are -r-ing FSharp.Core 4.0 but mscorlib 2.0. Be sure to pass explicit references to both on the command-line. Check the Output Window in Visual Studio when you build for a sample command-line.

EDIT

See this question:

FSharp.Compiler.CodeDom for VS2008 and VS2010 side-by-side



回答2:

Check what version of .NET you're running against on your dev machine, vs the one in production. The easiest way of doing this is probably to print out System.Environment.Version.

I suspect you'll find that your dev machine is using .NET 3.5, and your production machine is using .NET 2.0, or something like that. Check which application pool your application is running in, and you can set the version for that application pool.



回答3:

Is your dev machine 32 or 64 bit? Looks like the server is 64, and so it may be a an issue if they are different.