Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MissingMethodException when running a unit test that uses FSharp.Data

I have a NUnit unit test that is written in a normal F# library but targets F# code in a Portable Class Library.

When I run this test (in Visual Studio 2013), I get the following exception:

Result Message: System.MissingMethodException : Method not found:
 'Microsoft.FSharp.Control.FSharpAsync`1<System.IO.TextReader> FSharp.Data.Runtime.IO.asyncReadTextAtRuntime(System.Boolean, System.String, System.String, System.String, System.String)'.

This is what I have in my app.config in the Portable Class Library:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

This is what I have in the app.config of my normal F# library:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <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.3.1.0" newVersion="4.3.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.3.13283" newVersion="2.6.3.13283" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
like image 456
Tiago Avatar asked Apr 30 '14 13:04

Tiago


1 Answers

The MissingMethodException means exactly that (in terms of signature).

It sounds like your test code doesn't have a reference to the version of FSharp.Data DLL that your portable library is using.

The method signature for asyncReadTextAtRuntime was changed very recently, so you must reference the latest version in your test project.

See this GitHub commit, where the function was altered to take an additional parameter called formatName:

https://github.com/fsharp/FSharp.Data/commit/be3651f314b7a13b57a755a728287373adda775d#diff-a47e4306ce1338946e18435ee1e97c50R304

like image 53
Scott Avatar answered Sep 23 '22 14:09

Scott