【问题标题】:C# class - System.MissingMethodException when in FSIC# 类 - 在 FSI 中时的 System.MissingMethodException
【发布时间】:2014-03-31 08:32:07
【问题描述】:

我的行为很奇怪。

我正在尝试使用 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# 库是否存在一些特定的黑客行为?

Tnx.

【问题讨论】:

  • 你是否也引用了fsi中的json dll?
  • 是的,我做到了。我也尝试过降级 json dll
  • 我认为 json 中缺少的 dll 是一个错字?
  • 这一定是DLL Hell问题。使用 Fuslogvw.exe 并记录所有绑定,以便了解在 FSI 中运行时 Newtonsoft.Json.dll 的来源。
  • 检查您在 fsi 和您的 F# 应用程序中使用的 .net 和 F# 版本。

标签: c# f# missingmethodexception fsi


【解决方案1】:

以管理员身份运行 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"

【讨论】:

  • 以管理员身份运行解决了一个问题。我不知道为什么。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多