在我的Xamarin Forms项目中,当我调用一个使用来自iOS项目的Realm(具有公共代码的项目)的函数时,我得到以下异常。从Android项目它工作正常。尝试使用Realm.GetInstance()
获取Realm实例时发生异常。知道为什么会这样,以及如何解决它?
{System.TypeInitializationException: The type initializer for 'Realms.SharedRealmHandle' threw an exception. ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Realms.SynchronizationContextEventLoopSignal:GetCurrentSynchronizationContext ()' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_delegate_to_ftnptr(object)
at (wrapper managed-to-native) Realms.SynchronizationContextEventLoopSignal.install_eventloop_callbacks(Realms.SynchronizationContextEventLoopSignal/get_eventloop,Realms.SynchronizationContextEventLoopSignal/post_on_event_loop,Realms.SynchronizationContextEventLoopSignal/release_eventloop)
at Realms.SynchronizationContextEventLoopSignal.Install () [0x0003b] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/Native/SynchronizationContextEventLoopSignal.cs:122
at Realms.NativeCommon.Initialize () [0x00119] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/Native/NativeCommon.cs:91
at Realms.SharedRealmHandle..cctor () [0x00000] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/Handles/SharedRealmHandle.cs:124
--- End of inner exception stack trace ---
at Realms.RealmConfiguration.CreateRealm (Realms.Schema.RealmSchema schema) [0x000b4] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/RealmConfiguration.cs:153
at Realms.Realm.GetInstance (Realms.RealmConfigurationBase config, Realms.Schema.RealmSchema schema) [0x0003f] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/Realm.cs:138
at Realms.Realm.GetInstance (Realms.RealmConfigurationBase config) [0x00000] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/Realm.cs:80
at Realms.Realm.GetInstance (System.String databasePath) [0x00000] in /Users/realm/workspace/realm_realm-dotnet_PR-1723/Realm/Realm/Realm.cs:67
at NumeropakettiMobile.LocalDB+<UpdateDB>d__0.MoveNext () [0x00023] in /Users/lasse/Code/numeropaketti_mobile/NumeropakettiMobile/NumeropakettiMobile/LocalDB.cs:17 }