4

I have written ATs for my application in F# using Tickspec. I am using FSharp.Data.Http.Request and I am getting the following error:

System.MissingMethodException : Method not found: 'FSharp.Data.HttpResponse     
FSharp.Data.Http.Request(System.String,  
Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Collections.FSharpList`1
<System.Tuple`2<System.String,System.String>>>,  
Microsoft.FSharp.Core.FSharpOption`1<System.Collections.Generic.IEnumerable`1
<System.Tuple`2<System.String,System.String>>>,   
Microsoft.FSharp.Core.FSharpOption`1<System.String>,   
Microsoft.FSharp.Core.FSharpOption`1<FSharp.Data.HttpRequestBody>,    
Microsoft.FSharp.Core.FSharpOption`1<System.Collections.Generic.IEnumerable`
1<System.Tuple`2<System.String,System.String>>>,
Microsoft.FSharp.Core.FSharpOption`1<System.Net.CookieContainer>, 
Microsoft.FSharp.Core.FSharpOption`1<Boolean>, 
Microsoft.FSharp.Core.FSharpOption`1<System.String>, 
Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Core.FSharpFunc`2
<System.Net.HttpWebRequest,System.Net.HttpWebRequest>>)'.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] 
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, 
Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags 
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at <StartupCode$TickSpec>.$TickSpec.createAction@212-1.Invoke()

FSharp.Data version is 2.1.1.0.

In fsproj:

ToolsVersion is 14.0

TargetFrameworkVersion is v4.6.1

F# is 4.0.

I have another set of ATs for a different application and I am using the same FSharp.Data.dll and the same Http.Request method and they use F# 4.0 and I encountered no problems.

I don't think there is any problem with the dll as I used it in a sample app and I was able to use that Http.Request method. I created a brand new solution as I thought maybe I was using an old version of FSharp.Core and still the same problem with FSharp.Data.

The only solution I found was to revert back to F#3.0 for that particular project. I do not want to use F#3.0 though as we have moved on to F#4.0 with all other application.

Any idea how to solve this?

Marta
  • 1,132
  • 1
  • 10
  • 26

2 Answers2

2

Add an app.config or the following to any existing one. If you have multiple projects. i.e. test and application you will need to add it to both.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
jps
  • 1,060
  • 12
  • 19
1

Sounds like you're somehow binding to F#3.x in FSI. Can you see in your script (if you're executing this via a script) which version of FSharp.Core is being referenced?

If I remember correctly, TickSpec is compiled against F3.x, so this could be a binding redirects issue or similar.

Isaac Abraham
  • 3,422
  • 2
  • 23
  • 26
  • There was no reference to `FSharp.Core`. I added it and the `MissingMethodException` is gone. The `FSharp.Core` version is `4.3.0.0` - is this correct for `F#4.0`? According to this: https://fsharp.github.io/2015/04/18/fsharp-core-notes.html#do-not-bundle-fsharp-core-with-a-library I should be referencing `FSharp.Core 4.4.0.1` for `F#4.0`, although when I do, the `MethodMissingException` re-appears... – Marta Sep 12 '16 at 08:59
  • 1
    When you add the reference, do you add a binding redirect in your configuration file? – Isaac Abraham Sep 13 '16 at 17:03
  • 1
    You'll probably need to then - see answer below - that might do the trick. – Isaac Abraham Sep 15 '16 at 12:27