Dotmim.Sync: TryConvertTo does not work on IOS when using dynamic
Hi!
When I add parameter in a Xamarin(iOS) client, I am receiving the following error:
Dotmim.Sync.SyncException: byref delegate ---> System.NotImplementedException: byref delegate
at System.Linq.Expressions.Interpreter.LightLambda.CreateCustomDelegate (System.Type delegateType) [0x001cf] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightLambda.cs:422
at System.Linq.Expressions.Interpreter.LightLambda.MakeDelegate (System.Type delegateType) [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightLambda.cs:446
at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate (System.Runtime.CompilerServices.IStrongBox[] closure) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightDelegateCreator.cs:33
at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightDelegateCreator.cs:28
at System.Linq.Expressions.Expression`1[TDelegate].Compile (System.Boolean preferInterpretation) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs:211
at System.Linq.Expressions.Expression`1[TDelegate].Compile () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs:192
at System.Runtime.CompilerServices.CallSite`1[T].CreateCustomNoMatchDelegate (System.Reflection.MethodInfo invoke) [0x0002b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs:668
at System.Runtime.CompilerServices.CallSite`1[T].MakeUpdateDelegate () [0x00010] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs:304
at System.Runtime.CompilerServices.CallSite`1[T].GetUpdateDelegate (T& addr) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs:234
at System.Runtime.CompilerServices.CallSite`1[T].GetUpdateDelegate () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs:224
at System.Runtime.CompilerServices.CallSite`1[T]..ctor (System.Runtime.CompilerServices.CallSiteBinder binder) [0x00007] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs:167
at System.Runtime.CompilerServices.CallSite`1[T].Create (System.Runtime.CompilerServices.CallSiteBinder binder) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs:216
at Dotmim.Sync.SyncTypeConverter.TryConvertTo[T] (System.Object value, System.Globalization.CultureInfo provider) [0x012e7] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.SyncTypeConverter.TryConvertFromDbType (System.Object value, System.Data.DbType typeOfT, System.Globalization.CultureInfo provider) [0x00097] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.DbSyncAdapter.SetParameterValue (System.Data.Common.DbCommand command, System.String parameterName, System.Object value) [0x0002b] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.DbSyncAdapter.SetColumnParametersValues (System.Data.Common.DbCommand command, Dotmim.Sync.SyncRow row) [0x00072] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.DbSyncAdapter+<>c__DisplayClass24_0.<ApplyChangesAsync>b__0 () [0x0007e] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.DbSyncAdapter+<>c__DisplayClass24_0.<ApplyChangesAsync>b__0 () [0x00376] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.DbSyncAdapter.ApplyChangesAsync (Dotmim.Sync.SyncContext context, System.Guid localScopeId, System.Guid senderScopeId, Dotmim.Sync.SyncTable changesTable, System.Int64 lastTimestamp, System.Collections.Generic.List`1[T] conflicts, Dotmim.Sync.InterceptorWrapper`1[T] iTableChangesBatchApplying, System.Data.Common.DbConnection connection, System.Data.Common.DbTransaction transaction, System.Threading.CancellationToken cancellationToken) [0x002ce] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.BaseOrchestrator.InternalApplyTableChangesAsync (Dotmim.Sync.SyncTable schemaTable, Dotmim.Sync.SyncContext context, Dotmim.Sync.MessageApplyChanges message, System.Data.Common.DbConnection connection, System.Data.Common.DbTransaction transaction, System.Data.DataRowState applyType, Dotmim.Sync.DatabaseChangesApplied changesApplied, System.Threading.CancellationToken cancellationToken, System.IProgress`1[T] progress) [0x004ac] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.BaseOrchestrator.InternalApplyChangesAsync (Dotmim.Sync.SyncContext context, Dotmim.Sync.MessageApplyChanges message, System.Data.Common.DbConnection connection, System.Data.Common.DbTransaction transaction, System.Threading.CancellationToken cancellationToken, System.IProgress`1[T] progress) [0x004d4] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.LocalOrchestrator+<>c__DisplayClass7_0.<ApplyChangesAsync>b__0 (Dotmim.Sync.SyncContext ctx, System.Data.Common.DbConnection connection, System.Data.Common.DbTransaction transaction) [0x00151] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.BaseOrchestrator.RunInTransactionAsync[T] (Dotmim.Sync.Enumerations.SyncStage stage, System.Func`4[T1,T2,T3,TResult] actionTask, System.Threading.CancellationToken cancellationToken) [0x00239] in <1938b9d809814d548672472ac82fe072>:0
--- End of inner exception stack trace ---
at Dotmim.Sync.BaseOrchestrator.RaiseError (System.Exception exception) [0x00046] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.BaseOrchestrator.RunInTransactionAsync[T] (Dotmim.Sync.Enumerations.SyncStage stage, System.Func`4[T1,T2,T3,TResult] actionTask, System.Threading.CancellationToken cancellationToken) [0x00376] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.BaseOrchestrator.RunInTransactionAsync[T] (Dotmim.Sync.Enumerations.SyncStage stage, System.Func`4[T1,T2,T3,TResult] actionTask, System.Threading.CancellationToken cancellationToken) [0x00429] in <1938b9d809814d548672472ac82fe072>:0
at Dotmim.Sync.SyncAgent.SynchronizeAsync (Dotmim.Sync.Enumerations.SyncType syncType, System.Threading.CancellationToken cancellationToken, System.IProgress`1[T] progress) [0x00cca] in <1938b9d809814d548672472ac82fe072>:0
at MyApp.Services.DatabaseSyncService.SyncDatabase () [0x000e9] in /Users/akshaygaur/Documents/MyApp/Services/DatabaseSyncService.cs:55
Without the parameter, the sync happens happily (without any rows of course because of missing parameter)
Synchronization done.
Total changes uploaded: 0
Total changes downloaded: 0
Total changes applied: 0
Total resolved conflicts: 0
Total duration :0:0:3.137
I am using Web API to expose my database to my client systems. There are filters on all the tables so that only the relevant information gets sent down to the clients. Luckily, there is only one parameter. The server setup is pretty straight forward affair:
services.AddMemoryCache();
var setup = new SyncSetup(SyncSetupHelper.tables);
var options = new SyncOptions();
SyncSetupHelper.AddFilters(setup);
services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, setup);
When testing this setup with a Console (.net core), I am not having any issues with syncing with the server (the same code is being used in both Xamarin and Console app):
var serverOrchestrator = new WebClientOrchestrator("https://c8fc559e2d5f.ngrok.io/api/sync");
var clientProvider = new SqliteSyncProvider(clientConnectionString);
var agent = new SyncAgent(clientProvider, serverOrchestrator);
if (!agent.Parameters.Contains("Id"))
{
var filterId = new Guid("5D25A2C1-209F-44F7-842C-CFD9D47864DE");
agent.Parameters.Add("Id", filterId);
}
do
{
var s1 = await agent.SynchronizeAsync();
Console.WriteLine(s1);
} while (Console.ReadKey().Key != ConsoleKey.Escape);
Console.WriteLine("End");
I am hoping that I am doing something silly and missing something obvious. Any help or guidance is appreciated!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (17 by maintainers)
Done!
I think I am beginning to understand this issue a little better. I believe (this is only a hunch) that whenever there is something to download from the server, the error is being thrown. This is the only logical explanation of what I am seeing so far.
@Mimetis Downloading the code onto my machine and debugging it is literally what popped into my head late yesterday. I will try to do this today.
Did you try to call
SQLitePCL.Batteries.Init()on IOS ? It’s mandatory otherwise It won’t work on IOS.Here are the guidelines : https://github.com/ericsink/SQLitePCL.raw/wiki/SQLitePCL.Batteries.Init#where-should-i-call-sqlitepclbatteries_v2init
Let me know if it’s resolving your issue