In a cross-platform project we use Akavache as our cache. The target is .Net Standard 2.1, and we use version 6.10.20.
We simply use the following for writing:
await cache.InsertObject(userIDKey, userID);
For reading:
await cache.GetObject<Guid>(userIDKey);
It works on Xamarin.Android, for both reading and writing.
Unfortunately, we can only write in Xamarin.iOS (the cache does contain the item).
When we try to read it, the following exception occurs:
Operation is not supported on this platform.
Stacktrace: at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] parameterTypes, System.Type owner, System.Boolean skipVisibility) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.notsupported.cs:74 \n at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.BuildTypeNoCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00038] in :0 \n at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.BuildType (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00055] in :0 \n at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.Build (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00039] in :0 \n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CompiledServiceProviderEngine.RealizeService (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00006] in :0 \n at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>n__0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00000] in :0 \n at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+<>c__DisplayClass1_0.b__1 () [0x00000] in :0 \n at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534 \n at System.Threading.Tasks.Task.Execute () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 \n"
We use the following environment:
- OS: iOS 13.5
- Device: Simulator 11.5
- Xamarin: 16.6.000.1062 (d16-6@41e1f0e)
- Xamarin.iOS and Xamarin.Mac SDK 13.18.2.1 (29c4ea7)
It is very strange that writing works yet the same object can't retrieve the data.
What could cause this?