Dotmim.Sync SqliteSyncProvider在Xamarin IOS中引发异常|离线同步

问题描述 投票:0回答:1

我正在尝试将Dotmim.Sync与我的Xamarin IOS项目一起使用。我在解决方案中添加了一个.net standard 2.0项目。添加了Dotmim.Sync.Sqlite和Dotmim.Sync.Web.Client块。这是SyncService代码:

  public async Task SyncAsync()
  {
     var proxyClientProvider = new WebClientOrchestrator("https://localhost:44358/api/sync");
     var clientProvider = new SqliteSyncProvider("mymobile.db");

     var progress = new SynchronousProgress<ProgressArgs>(s => Console.WriteLine($"{s.Context.SyncStage}:\t{s.Message}"));
     var agent = new SyncAgent(clientProvider, proxyClientProvider);
     do
     {
        // Launch the sync process
        var s1 = await agent.SynchronizeAsync(progress);
        // Write results
        Console.WriteLine(s1);

     } while (Console.ReadKey().Key != ConsoleKey.Escape);
     Console.WriteLine("End");
}

我已将.net标准项目引用添加到我的iOS项目中,并称为Sync Service类(仅用于POC)。

 mButton.TouchUpInside += (sender, e) =>
{
    SyncService sync = new SyncService();
    Sync. SyncAsync ();
 };

at

 var s1 = await agent.SynchronizeAsync(progress);

引发异常:

  System.NullReferenceException: Object reference not set to an instance of an object
  at SQLitePCL.raw.sqlite3_open_v2 (SQLitePCL.utf8z filename, SQLitePCL.sqlite3& db, 
  System.Int32 flags, SQLitePCL.utf8z vfs) [0x00000] in <15ecb38d58394d7b88b3f841a7dda078>:0
  at SQLitePCL.raw.sqlite3_open_v2 (System.String filename, SQLitePCL.sqlite3& db, 
  System.Int32 flags, System.String vfs) [0x0000e] in <15ecb38d58394d7b88b3f841a7dda078>:0
  At Microsoft. Data. Sqlite. SqliteConnection. Open () [0x00122] in 
 <9ffe4c48f3134a7b905b5da527410f26>:0
 at System.Data.Common.DbConnection.OpenAsync (System.Threading.CancellationToken 
 cancellationToken) [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.0/src/Xamarin.iOS/external/corefx/src/.    System.Data.Common/src/System/Data/Common/DbConnection.cs:122

-从上一个引发异常的位置开始的堆栈跟踪---

并且System.Console.ReadKey给出“此平台不支持该操作。”

欢迎任何建议/帮助。

sqlite xamarin.ios
1个回答
0
投票

您应该使用SQLitePCL.Batteries_V2.Init();

这是Xamarin限制的一部分。此处更多信息:https://docs.microsoft.com/en-us/dotnet/standard/data/sqlite/xamarin

关于Dotmim.Sync,在此处查看更多信息:https://github.com/Mimetis/Dotmim.Sync/issues/249#issuecomment-609025301

© www.soinside.com 2019 - 2024. All rights reserved.