.netf#fsi

FSharp Interactive won't start; can't find System.Runtime.dll


I've installed FSharp 4.1 through the Visual Studio 2017 installer, but FSI refuses to start:

PS C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0> .\fsi

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly
'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified.
   at Microsoft.FSharp.Compiler.Interactive.Shell.MainMain(String[] argv)

I assume I'm missing something in a PATH variable or something, but despite several reinstalls and repairs I can't get past this error.

Where is FSI looking for this dll, and what should I install to put it there?

Update:

I've tried a few things, with no change to the outcome:

I've dumped the fusion logs to a zip file and put it on my Google Drive. There's a whole bunch of failed bindings, System.Runtime, Version 4.1.0.0 being one of them.

Issue filed here: https://github.com/Microsoft/visualfsharp/issues/3178


Solution

  • This has now been resolved over at github, but for completeness, here's a summary.

    The problem was that I, for some reason, had registered FSharp.Core 4.1.0.0 in the GAC:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise>gacutil /l FSharp.Core
    Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
    Copyright (c) Microsoft Corporation.  All rights reserved.
    
    The Global Assembly Cache contains the following assemblies:
      FSharp.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
      FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
      FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
    
    Number of items = 3
    

    The third entry should not be there. I removed that:

    gacutil /uf "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
    

    After that, FSI and dotnet new started working correctly. To get Visual Studio to work, I also had to repair my VS installation and reboot, and now everything works.