Skip to content

TypeLoadException on ParseAndCheckProject #750

@kjnilsson

Description

@kjnilsson

TypeLoadException on ParseAndCheckProject on mono 4.8.0

Repro steps

  1. Install latest FCS from nuget (currently 12.0.2)

  2. using mono 4.8.0 create an .fsx file with the following contents (adjust path to .dll as required):


#!/usr/bin/env fsharpi
#r "./lib/FSharp.Compiler.Service.dll"
open System
open System.IO
open Microsoft.FSharp.Compiler.SourceCodeServices

let testModule = """module Test
   let square x = x * x
"""

let file = __SOURCE_DIRECTORY__ +  "/Test.fs"
File.WriteAllText(file, testModule)
let checker = FSharpChecker.Create(keepAssemblyContents=true)
let options =
  checker.GetProjectOptionsFromCommandLineArgs("Test", [|"-o:Test.dll";"-a";file|])
let checkProjectResults =
  checker.ParseAndCheckProject(options) |> Async.RunSynchronously

  1. Run .fsx file using fsharpi.

Expected behavior

No error.

Actual behavior

Throws TypeLoadException exception:

System.TypeLoadException: Could not load type 'Microsoft.FSharp.Compiler.NameResolution+TcSymbolUses' from assembly 'FSharp.Compiler.Service, Version=12.0.2.0, Culture=neutral, PublicKeyToken=null'.
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CancellableModule+tryFinally@794[a].Invoke (Microsoft.FSharp.Core.FSharpChoice`2[T1,T2] res) [0x00023] in <58de824bddab8ea7a74503834b82de58>:0
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CancellableModule+bind@726[b,a].Invoke (System.Threading.CancellationToken ct) [0x00037] in <58de824bddab8ea7a74503834b82de58>:0
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CancellableModule.run[a] (System.Threading.CancellationToken ct, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Cancellable`1[TResult] _arg1) [0x0001c] in <58de824bddab8ea7a74503834b82de58>:0
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CancellableModule+bind@726[b,a].Invoke (System.Threading.CancellationToken ct) [0x00044] in <58de824bddab8ea7a74503834b82de58>:0
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CancellableModule+delay@766[T].Invoke (System.Threading.CancellationToken ct) [0x0000e] in <58de824bddab8ea7a74503834b82de58>:0
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CancellableModule.run[a] (System.Threading.CancellationToken ct, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Cancellable`1[TResult] _arg1) [0x0001c] in <58de824bddab8ea7a74503834b82de58>:0
  at <StartupCode$FSharp-Compiler-Service>.$Reactor+EnqueueAndAwaitOpAsync@146-2[T].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x0001a] in <58de824bddab8ea7a74503834b82de58>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f712f98eb8e445c8918edaf595bbe465>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a] (Microsoft.FSharp.Control.AsyncBuilderImpl+AsyncImplResult`1[T] res) [0x0002d] in <58a4c795dff9fae1a745038395c7a458>:0
  at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronouslyInCurrentThread[a] (System.Threading.CancellationToken token, Microsoft.FSharp.Control.FSharpAsync`1[T] computation) [0x00029] in <58a4c795dff9fae1a745038395c7a458>:0
  at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a] (System.Threading.CancellationToken token, Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout) [0x00014] in <58a4c795dff9fae1a745038395c7a458>:0
  at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T] (Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout, Microsoft.FSharp.Core.FSharpOption`1[T] cancellationToken) [0x00071] in <58a4c795dff9fae1a745038395c7a458>:0
  at <StartupCode$FSI_0001>.$FSI_0001.main@ () [0x000a5] in <27bf6b928de14166bc2bdc5ed8fc89cf>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <f712f98eb8e445c8918edaf595bbe465>:0

Provide a description of the actual behaviour observed.

Known workarounds

Version 0.0.89 is known to work ok.

Related information

Provide any related information

  • Operating system
    OSX
  • Branch
  • .NET Runtime, CoreCLR or Mono Version
    MONO 4.8.0
  • Editing Tools (e.g. Visual Studio Version)
    VIM but it shouldn't matter

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions