System.MissingMethodException when using specific methods from FSharp PowerPack and compiling into a class library

So, I am just starting with F #, and I encounter a very strange problem when I get a System.MissingMethodException when using certain methods from FSharp PowerPack.

This does not happen for all methods in the same module. This also does not happen if I compile my assembly as an application and not a class library.

Playback Stages:

  • Create 2 assemblies, one class library and one application.
  • Add nunit.framework and the FSharp.PowerPack libraries as references to both assemblies.
  • Create the following test fixture in each assembly.

    open NUnit.Framework [<TestFixture>] type Tests() = class [<Test>] member self.OfSeq() = // Will always succeed Matrix.Generic.ofSeq [[1]] |> ignore [<Test>] member self.OfList() = // Will fail under certain conditions with a System.MissingMethodException Matrix.Generic.ofList [[1]] |> ignore end 
  • Compile both assemblies.
  • Open each assembly in NUnit and run all the tests.

When I do this, the application works fine (all tests pass), but the class library crashes with the following exception:

 System.MissingMethodException : Method not found: 'Microsoft.FSharp.Math.Matrix`1<!!0> Generic.ofList(Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Collections.FSharpList`1<!!0>>)'. at Temp2.Tests.OfList() 

What's going on here?

Another method that creates the problem is matrix.PermuteColumns.

Additional Information:

  • I compile both assemblies for .NET 4.5
  • I am compiling with Visual Studio 2012 RC
  • I am using NUnit version 2.5.10.11092
  • I am using FSharp PowerPack version 2.1.3.1 (although the properties of the DLL indicate it is 2.0.0)

Let me know if there is additional information that will be helpful.

+8
f # missingmethodexception f # -powerpack
source share
2 answers

I wonder if this is due to redirect binding. You may need to copy the app.config file into the application project into the library project.

This seems like a known issue that I am currently writing on the blog of the F # team (possibly coming in the next few weeks) regarding MSTest, not NUnit. I would try copying the app.config file to the library project, and if that doesn't work, use the online template testing module here:

http://visualstudiogallery.msdn.microsoft.com/51ebe64a-899b-4959-8c24-b0148ed6b264

and additionally select "TEST \ Test Settings \ Select Test Settings File" from the menu in VS and specify it in the file "MSTest.runsettings" included in the unit test project template. I expect one of these two settings to be fixed in the case of MSTest.

+3
source share

(The answer is for future reference, since this Q was the first hit in the search.)

Since Visual Studio 2013 with the template for the online project โ€œF # MSTestโ€ referenced by Brian, none of Brianโ€™s suggestions helped (for starters, the test target is a library project without App.Config ).

However, in the end, I found that the test project was configured to use the F # 3 runtime (with FSharp.Core V4.3.0.0). Changing this parameter to F # v3.1 (FSharp.Core V4.3.1.0) fixed the problem.

+12
source share

All Articles