42

I'm trying to deploy a web application which uses F# 4.0 on Windows Server 2008.

It works on my computer where VS2010 is installed but it doesn't work on the server. Everytime you open the page you'll get this error message:

Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I've installed .NET 4 using the web platform installer. F# PowerPack is installed too.

I found this page: http://connect.microsoft.com/VisualStudio/feedback/details/507202/error-in-working-with-f It suggests you to reinstall F#, but the link to download F# seems to be broken. And it might not be the same problem I have.

I've also tried to install Microsoft F# 2.0.0.0 since it's the only F# redistribution I could find. But it doesn't help at all.

Has anyone get something like this to work?

bkaid
  • 51,465
  • 22
  • 112
  • 128
Ken
  • 449
  • 1
  • 4
  • 6

8 Answers8

21

I needed version 4.0.0 of FSharp.Core, so I installed it in my Visual Studio 2010 via Nuget:
http://nuget.org/packages/FSharp.Core

Or run the following command in the Package Manager Console:
PM> Install-Package FSharp.Core

Then publish the project and upload FSharp.Core.dll

Duc Filan
  • 6,769
  • 3
  • 21
  • 26
Luis Pereira
  • 211
  • 2
  • 3
  • Worked for me, to install `6.0.0` of `FSharp.Core` in `Visual Studio 2022`, and to fix this error message: "Unhandled exception. Cannot print exception string because Exception.ToString() failed.". – Stephen Hosking Jul 19 '22 at 03:23
20

You need to install the redist (F# runtime) on the deployment machine. See e.g.

http://msdn.microsoft.com/library/ee241127(VS.100).aspx (or http://msdn.microsoft.com/en-us/library/ee829875.aspx)

for info on how to have a VS project chain the installer. As you've found, the redist (located here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=5f0a79f8-925f-4297-9ae2-86e2fdcff33c&displaylang=en

) needs to be installed; FSharp.Core is not part of .NET, rather it is a separately installed component.

Brian
  • 117,631
  • 17
  • 236
  • 300
  • Thanks, that's what I was looking for. :D I didn't find the right version, the one I found was "F# 2.0 for Windows + Visual Studio 2008 (April 2010 release)." which I got from http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/release.aspx And since F# is a first-class programming language on .NET 4, at first I thought it'd be included in .NET 4 runtime. – Ken Jun 15 '10 at 10:53
4

I had the same problem and got it working by:

  1. Adding a reference to FSharp.Core in the web project (mine was a C# project)
  2. Changing Copy Local to True in the FSharp.Core reference properties
  3. Build and publish!
Troy Kershaw
  • 590
  • 3
  • 8
3

Just install this: Microsoft Visual Studio 2010 F# Runtime 2.0 on the server

http://www.microsoft.com/en-us/download/details.aspx?id=13450

Tom Stickel
  • 19,633
  • 6
  • 111
  • 113
2

I managed to get it working by installing FSharpRedist2.0 from VS2010 installer. It's located at \WCU\FSharp.

Ken
  • 449
  • 1
  • 4
  • 6
2

Just for anybody stumbling upon this after updating to VS 2019:

In my case, I have a C# console app that references an F# class library. All is good in VS 2017 but in VS 2019 I suddenly get such assembly loading errors (for FSharp.Core v4.7.0).

The reason behind the issue was that the FSharp.Core DLL somehow didn't get copied to the bin folder of the console app (though IMO it should, but it doesn't bother VS 2017). Since there is no copy local or similar option for a NuGet package I just added it to the console app as well. Not nice, but works.

Piedone
  • 2,693
  • 2
  • 24
  • 43
  • What do you mean @Andrii? – Piedone Jan 31 '20 at 20:59
  • ..\packages\FSharp.Core.4.7.0\lib\netstandard2.0\FSharp.Core.dll True – Andrii Feb 12 '20 at 23:04
  • Ah OK. The strange thing is that in my (.NET Core) F# project's fsproj file there is no reference to FSharp.Core anywhere (I guess VS automatically loads that somehow based on it being an fsproj). Probably it makes matters more complicated that the C# console app (the one that references the F# library) is .NET Framework. – Piedone Feb 13 '20 at 01:03
1

adding

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

to the *.csproj file helped me with the same problem. https://msdn.microsoft.com/en-us/library/2fc472t2%28v=vs.110%29.aspx

Goswin Rothenthal
  • 2,244
  • 1
  • 19
  • 32
1

In my case, this was caused by a corrupted config. I removed every reference to F# in the *.fsproj and *.csproj files (including binding redirects), reinstalled the FSharp.Core package from NuGet, and everything worked out nicely.