Class IncompatibleSyncedFileException
An exception thrown when attempting to open an incompatible Synchronized Realm file. This usually happens when the Realm file was created with an older version of the SDK and automatic migration to the current version is not possible. When such an exception occurs, the original file is moved to a backup location and a new file is created instead. If you wish to migrate any data from the backup location, you can use GetBackupRealmConfig(Byte[]) to obtain a RealmConfigurationBase that can then be used to open the backup Realm. After that, retry opening the original Realm file (which now should be recreated as an empty file) and copy all data from the backup file to the new one.
Inherited Members
Namespace: Realms.Sync.Exceptions
Assembly: Realm.Sync.dll
Syntax
public class IncompatibleSyncedFileException : RealmException
Examples
var syncConfig = new SyncConfiguration(user, serverUri);
try
{
var realm = Realm.GetInstance(syncConfig);
// Do something if call was successful.
}
catch (IncompatibleSyncedFileException ex)
{
var backupConfig = ex.GetBackupRealmConfig();
var backupRealm = Realm.GetInstance(backupConfig);
var realm = Realm.GetInstance(syncConfig);
realm.Write(() =>
{
foreach (var item in backupRealm.All("MyItem"))
{
realm.Add(new MyItem
{
Value = item.Value,
...
});
}
});
}
Methods
| Improve this Doc View SourceGetBackupRealmConfig(Byte[])
Gets a RealmConfigurationBase instance that can be used to open the backup Realm file.
Declaration
public RealmConfigurationBase GetBackupRealmConfig(byte[] encryptionKey = null)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | encryptionKey | Optional encryption key that was used to encrypt the original Realm file. |
Returns
Type | Description |
---|---|
RealmConfigurationBase | A configuration object for the backup Realm. |