找不到方法'Sockets.Plugin.Abstractions.ITcpSocketClient.ConnectAsync'(Neo4j驱动程序)

时间:2016-09-16 11:09:40

标签: .net xamarin neo4j

我正在尝试使用 Neo4j .Net驱动程序 Xamarin 应用程序中的本地Neo4j数据库进行通信。

这是我的代码:

using Neo4j.Driver.V1; // I have this at the top of the class

//and this in the constructor just to test it
using (var driver = GraphDatabase.Driver("bolt://localhost", AuthTokens.Basic("neo4j", "root")))
using (var session = driver.Session())
{
    session.Run("CREATE (a:User {name:'Arthur'})");
}

它们在网站(https://neo4j.com/developer/language-guides/)上作为示例提供的代码基本相同。

当我尝试运行项目时,我收到以下错误:

enter image description here

System.AggregateException: One or more errors occurred. ---> System.MissingMethodException: Method 'Sockets.Plugin.Abstractions.ITcpSocketClient.ConnectAsync' not found.
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00031] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:316
  at Neo4j.Driver.Internal.Connector.SocketClient.Start () [0x00023] in <d05dc2e6bd2a40acab42430b347d4724>:0
  at Neo4j.Driver.Internal.Connector.SocketConnection.<.ctor>b__3_0 () [0x00000] in <d05dc2e6bd2a40acab42430b347d4724>:0
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00014] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2157
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00052] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3189
  at System.Threading.Tasks.Task.Wait () [0x00000] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3054
  at Neo4j.Driver.Internal.Connector.SocketConnection..ctor (Neo4j.Driver.Internal.Connector.ISocketClient socketClient, Neo4j.Driver.V1.IAuthToken authToken, Neo4j.Driver.V1.ILogger logger, Neo4j.Driver.Internal.Messaging.IMessageResponseHandler messageResponseHandler) [0x00046] in <d05dc2e6bd2a40acab42430b347d4724>:0
  at Neo4j.Driver.Internal.Connector.SocketConnection..ctor (System.Uri url, Neo4j.Driver.V1.IAuthToken authToken, Neo4j.Driver.V1.Config config) [0x00016] in <d05dc2e6bd2a40acab42430b347d4724>:0
  at Neo4j.Driver.Internal.Session..ctor (System.Uri uri, Neo4j.Driver.V1.IAuthToken authToken, Neo4j.Driver.V1.Config config, Neo4j.Driver.Internal.Connector.IConnection conn, System.Action`1[T] releaseAction) [0x0005c] in <d05dc2e6bd2a40acab42430b347d4724>:0
  at Neo4j.Driver.Internal.SessionPool.<GetSession>b__14_0 () [0x0003b] in <d05dc2e6bd2a40acab42430b347d4724>:0
  at Neo4j.Driver.Internal.LoggerBase.TryExecute[T] (System.Func`1[TResult] func) [0x00000] in <d05dc2e6bd2a40acab42430b347d4724>:0

我尝试查看Neo4j手册(http://neo4j.com/docs/operations-manual/current/)并在线搜索,但找不到解决方案。

1 个答案:

答案 0 :(得分:1)

如果你看看最新的Neo4J驱动程序: https://www.nuget.org/packages/Neo4j.Driver/1.0.2

您会看到它依赖于rda.SocketsForPCL(&gt; = 1.2.2)

Neo4J尝试调用的方法在最新的rda.SocketsForPCL中被修改: https://www.nuget.org/packages/rda.SocketsForPCL/2.0.2

开发者的评论是:

  

TcpSocketClient&#39; ConnectAsync方法可选择使用   CancellationToken支持客户端调用的取消和   超时等场景。谢谢@SparkStream

您的错误是:

  

方法&#39; Sockets.Plugin.Abstractions.ITcpSocketClient.ConnectAsync&#39;不   找到。

解决方案是:

选择早期版本的rda.SocketsForPCL(例如1.2.2,这绝对有效),你的问题就会消失。

例如,如果您正在使用NuGet的paket依赖项管理器,则可以将以下内容添加到 paket.dependencies 文件中:

nuget rda.SocketsForPCL ~> 1
祝你好运!