I have the following code:
open FSharp.Data
[<Literal>]
let connectionString = @"Data Source=(local)\SQLExpress;Integrated Security=SSPI;Database=SfagStage"
type InsertEnhet = SqlCommandProvider<"Sql\InsertEnhet.sql", connectionString>
let insertEnhet (enhet:Enhet) =
let cmd = new InsertEnhet() // <<--- This generates an error runtime
cmd.Execute(enhet.Navn, enhet.Enhetsnummer, enhet.LEIKode, enhet.Kommune, DateTime.Now)
The row where I create the command is what causing the missing method I think. The part that of the exception that I think matters is:
System.MissingMethodException: Method not found: 'Void FSharp.Data.ISqlCommand Implementation..ctor(FSharp.Data.Connection, Int32, System.String, Boolean, System.Data.SqlClient.SqlParameter[], FSharp.Data.ResultType, FSharp.Data.ResultRank, Microsoft.FSharp.Core.FSharpFunc`2, System.String)'.
This is the kind of exception that you may get when you don't have correct bindingRedirect
for FSharp.Core.dll
. Check out this article by Mark Seemann. In principle, I think that adding app.config
with bindingRedirect
to your application should solve the problem.
This typically happens when using a library that is compiled against older version of FSharp.Core in an application that uses newer version of FSharp.Core. The .NET runtime loads the new version of FSharp.Core but it does not know that types from the older version (like FSharpFunc
) should be mapped to corresponding types in the new version - and so you get MethodMissing, because .NET thinks that FSharpFunc
is a different type than the loaded one. (Though things get a bit more complicated with type providers.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With