-
Notifications
You must be signed in to change notification settings - Fork 173
Description
What happened?
I'm using realm db in one of my projects based on Maui which uses .net8 SDK, and app is working fine in both android and iOS.
Recently we upgraded Maui project with .net10 RC 1, and noticed Ream does not work in iOS app, we are able to build projects successfully, but as soon I run the app, it is logging below error.
The type initializer for 'Realms.SharedRealmHandle' threw an exception.
---> System.DllNotFoundException: realm-wrappers
However same thing is working fine in android app, only iOS app has problem.
Currently my project uses Realm version 11.6.1, I have tried with latest version 20.1.0, and some other Realm version also, but only in iOS I'm getting above error.
I have tried cleaning and rebuild, disable linker also but problem still exists.
Is it Realm 20.0.1 is not compatible with .net 10 RC1
Realm DB Error getting Realm database instance (Mobile.LocalDatabaseService) System.TypeInitializationException: The type initializer for 'Realms.SharedRealmHandle' threw an exception.
---> System.DllNotFoundException: realm-wrappers
at Realms.SynchronizationContextScheduler.Initialize()
at Realms.NativeCommon.Initialize()
at Realms.SharedRealmHandle..cctor()
at Realms.RealmConfiguration.CreateHandle(Configuration& configuration)
at Realms.RealmConfigurationBase.CreateRealm()
at Realms.Realm.GetInstance(RealmConfigurationBase config)
at Mobile.LocalDatabaseService.GetRealmDbInstance() in /Mobile/Services/LocalDatabaseService.cs:line 45
Repro steps
- Create a Maui app, with .net10 RC 1 , that have android and iOS version
- Add Realm 20.0.1 version.
- On App start add logic to access db instance.
When we run iOS app it will result in error, while android one works
Version
.net10 RC 1
What Atlas Services are you using?
Local Database only
What type of application is this?
Other
Client OS and version
Maui iOS App
Code snippets
public LocalDatabaseService(IEnvironmentService environmentService)
{
try
{
_logger = Serilog.Log.ForContext();
_realmConfiguration = new RealmConfiguration
{
ShouldDeleteIfMigrationNeeded = environmentService.DeleteLocalDbIfMigrationNeeded,
SchemaVersion = 7,
MigrationCallback = (migration, oldSchemaVersion) =>
{
// Add migration scripts here
}
};
}
catch(Exception ex)
{
_logger.Error(ex, "Realm DB Error initializing LocalDatabaseService");
}
}
public Realm GetRealmDbInstance()
{
try
{
Realm realm = Realm.GetInstance(_realmConfiguration);
return realm;
}
catch (Exception ex)
{
_logger.Error(ex, "Realm DB Error getting Realm database instance");
return null;
}
}
Stacktrace of the exception/crash you're getting
ealm DB Error getting Realm database instance (Mobile.LocalDatabaseService) System.TypeInitializationException: The type initializer for 'Realms.SharedRealmHandle' threw an exception.
---> System.DllNotFoundException: realm-wrappers
at Realms.SynchronizationContextScheduler.Initialize()
at Realms.NativeCommon.Initialize()
at Realms.SharedRealmHandle..cctor()
at Realms.RealmConfiguration.CreateHandle(Configuration& configuration)
at Realms.RealmConfigurationBase.CreateRealm()
at Realms.Realm.GetInstance(RealmConfigurationBase config)
at Mobile.LocalDatabaseService.GetRealmDbInstance() in /Mobile/Services/LocalDatabaseService.cs:line 45