2016-09-16 55 views
1

我試圖使用Neo4j的淨驅動當地的Neo4j數據庫溝通,從Xamarin應用程序中。法「Sockets.Plugin.Abstractions.ITcpSocketClient.ConnectAsync」未找到(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

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

你會看到它有rda.SocketsForPCL依賴(> = 1.2.2)

方法的Neo4j試圖調用是修改最新rda.SocketsForPCL: https://www.nuget.org/packages/rda.SocketsForPCL/2.0.2

開發者的評論是:

TcpSocketClient 's ConnectAsync method optionally takes a CancellationToken to support client-invoked cancellation and scenarios like timeout. Thanks @SparkStream

你的錯誤是:

Method 'Sockets.Plugin.Abstractions.ITcpSocketClient.ConnectAsync' not found.

解決辦法是:

選擇rda.SocketsForPCL(如1.2.2,這絕對作品)的早期版本,你的問題就會迎刃而解。

例如,如果您使用的是的NuGet的一攬子貸款依賴管理器,你可以添加以下到您的paket.dependencies文件:

nuget rda.SocketsForPCL ~> 1 

祝你好運!

+0

謝謝!這解決了這個問題。然後,我只需要將「bolt:// localhost」更改爲「bolt://127.0.0.1:7687」,以便完美地工作 –