C# class - System.MissingMethodException when in FSI

本文关键字:when in FSI MissingMethodException System class | 更新日期: 2023-09-27 17:55:47

我以一种奇怪的行为运行。

我正在尝试使用C#库:Neo4jClient

我在 FSI 中的代码如下所示:

#r "Neo4jClient.dll"
#r "Newtonsoft.Json"

open System
open Neo4jClient
// Define your library scripting code here
let client = new GraphClient(new Uri("http://localhost:7474/db/data"))
client.Connect()

并导致以下错误:

System.MissingMethodException: Method not found: 'Void Newtonsoft.Json.JsonReader.set_DateParseHandling(Newtonsoft.Json.DateParseHandling)'.
   at Neo4jClient.Serialization.CustomJsonDeserializer.Deserialize[T](String content)
   at Neo4jClient.HttpContentExtensions.ReadAsJson[T](HttpContent content, IEnumerable`1 jsonConverters) in c:'TeamCity'buildAgent'work'5bae2aa9bce99f44'Neo4jClient'HttpContentExtensions.cs:line 20
   at Neo4jClient.GraphClient.Connect() in c:'TeamCity'buildAgent'work'5bae2aa9bce99f44'Neo4jClient'GraphClient.cs:line 188
   at <StartupCode$FSI_0013>.$FSI_0013.main@() in C:'Users'Mattia'Documents'Visual Studio 2012'Projects'GenChi'GenChiSnooper'Script.fsx:line 12

但是,如果作为 F# 应用程序执行,则相同的代码将正常运行。

open System
open Neo4jClient
[<EntryPoint>]
let main argv = 
    let client = new GraphClient(new Uri("http://localhost:7474/db/data"))
    client.Connect();
    printfn "Went through..."
    printfn "%A" argv
    0 // return an integer exit code

我不确定这个问题是否特定于库。我的问题是:在 FSI 中使用 C# 库是否有一些特定的黑客攻击?

咔嚓。

C# class - System.MissingMethodException when in FSI

以管理员身份运行Visual Studio。 并参考最新的Newtonsof.Json包:

#I @"..'packages'Neo4jClient.1.0.0.652'lib'net40"
#I @"..'packages'Newtonsoft.Json.6.0.2'lib'net45"
#r "Neo4JClient.dll"
#r "Newtonsoft.Json.dll"
let client = new GraphClient(new Uri("http://host:7474/db/data"))
client.Connect()
printfn "conntected"