FSharp.数据& # 39;System.MissingMethodException& # 39;当从c#调用Fr

本文关键字:调用 Fr 当从 MissingMethodException 数据 FSharp System | 更新日期: 2023-09-27 17:53:03

嗨,我在f#上有这段代码,如果我从f#交互式编辑器中测试它,isPalindrome和Extract方法都工作得很好:

namespace Portable3
open FSharp
open FSharp.Data
open Microsoft.FSharp.Linq 
open FSharp.Data.FreebaseOperators
open MyTrip.Model.MyTrip
open MyTrip.Model.FreeBase
open System.Runtime
open System.Linq
module math = 
let isPalindrome (str : string) = 
 let rec check(s : int, e : int) =
    if s = e then true
    elif str.[s] <> str.[e] then false
    else check(s + 1, e - 1)
 check(0, str.Length - 1)
 [<AutoOpen>]
 module Extractor =
[<Literal>] 
let FreebaseApiKey = "AIzaSyCO31Ls"
type FreebaseDataWithKey = FreebaseDataProvider<Key=FreebaseApiKey>
let Extract mid = let dataWithKey = FreebaseDataWithKey.GetDataContext()
                  let place = dataWithKey.Commons.Travel.``Travel destinations``.Where( fun x-> x.MachineId = mid) |> Seq.toList                           
                  let result = new Place()   
                  let firstPlace = place.Head
                  result.Name <- firstPlace.Name                      
                  result

我在c#控制台应用程序中像这样调用这段代码:

 class Program
{
    static void Main(string[] args)
    {
        //Works well
        var isPalin = math.isPalindrome("ABsBA");
        //fails
        var res = Extractor.Extract("/m/04jpl");
        Console.WriteLine(res);
        Console.Read();
    }
}

控制台c#项目是。net Framework 4.5.1版本,我下载了FSharp。数据和FSharp。这个项目也是核心。当执行isPalindrome工作良好,但当我要执行提取方法这个错误出现:

An unhandled exception of type 'System.MissingMethodException' occurred in FsharpConsoleTest.exe
Additional information: Method not found: 'FSharp.Data.Runtime.Freebase.FreebaseDataContext   FSharp.Data.Runtime.Freebase.FreebaseDataContext._Create(System.String, System.String, System.Boolean, System.String, System.Boolean, System.Boolean)'.

知道发生了什么事吗?我在网上搜索了一下,但没有找到任何相关的东西。谢谢!

FSharp.数据& # 39;System.MissingMethodException& # 39;当从c#调用Fr

最后的问题是使用带有FSharp.Data的便携式库。我试着在一个普通的f#库中使用它,我没有发现任何问题,我有所有的调试功能,并且没有发生c#与f#集成的错误!