realm-dotnet: Realms.Exceptions.RealmFileAccessErrorException: Unable to open a realm at path

Goals

Reliable realm database creation.

Expected Results

Realm instance.

Actual Results

Realms.Exceptions.RealmFileAccessErrorException: ‘Unable to open a realm at path ‘C:\Users\Václav\AppData\Local\Packages\7539ef42-e9e8-4e55-8c45-547c7a6ee489_v1yjhd5ekz562\LocalCache\realmtest.realm.management’: make_dir() failed: No such file or directory.’

Steps to Reproduce

Simple project for bug reproduction: https://1drv.ms/u/s!AlFEHk1e5ZDCoL1NodRClQwLeQdO6A

Code Sample

class RealmEntity : RealmObject {
    [PrimaryKey]
    public long Id { get; set; }
}

readonly static RealmConfiguration config = new RealmConfiguration(Path.Combine(ApplicationData.Current.LocalCacheFolder.Path, "realmtest.realm")) {
    SchemaVersion = 1,
    ObjectClasses = new Type[] { typeof(RealmEntity) },
    ShouldDeleteIfMigrationNeeded = true
};

async void Page_Loaded(object sender, RoutedEventArgs e) {
    using (var realm = await Realm.GetInstanceAsync(config)) {
    }
}

Version of Realm and Tooling

  • Client NuGet package version: 2.2.0
  • Client OS & Version: Windows 10 version 1709 (build 16299.248)

Hint

I think (but I cannot be sure) that instance creation fails because of lack of UTF-8 support. The directory path contains non-ascii characters. I can reproduce this issue only on user accounts with non-ascii characters in the profile directory path.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Yes, I was hoping to do a point release this week.

This is actually a very serious issue, since realm-dotnet cannot be reliably used with UWP apps that run sandboxed. It is very likely that user’s profile folder contains non-ascii characters. It looks like the issue resides at realm-core’s file.cpp where _mkdir function is used and _wmkdir should be used instead. I’m not experienced in C++, but I assume that it cannot be safely switched to use _wmkdir because the same core is compiled for multiple platforms.