【问题标题】:UWP - Unable to load DLL 'realm-wrappers'UWP - 无法加载 DLL 'realm-wrappers'
【发布时间】:2017-12-21 10:45:12
【问题描述】:

我有一个在 Win10 上使用 Visual Studio 2017 创建的 Xamarin/Realm 应用程序。它针对 iOS、Android 和 UWP。我正在尝试在 Windows 和 macOS 上构建此解决方案。

我在 macOS 中添加了 Realm,并在 Android 和 iOS 上成功测试了我的应用程序。然后当我搬回我的Windows机器时。它目前针对的是 UWP。当我在本地计算机上运行应用程序时,我看到以下运行时异常:

System.TypeInitializationException occurred
  HResult=0x80131534
  Message=The type initializer for 'Realms.Realm' threw an exception.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at Realms.Realm.GetInstance(RealmConfigurationBase config)
   at MouseDroid.MainPageViewModel..ctor() in C:\Users\hmurphy\Documents\Pittsh\Projects\mouse_droid\MouseDroid\MainPageViewModel.cs:line 20
   at MouseDroid.MainPage..ctor() in C:\Users\hmurphy\Documents\Pittsh\Projects\mouse_droid\MouseDroid\MainPage.xaml.cs:line 28
   at MouseDroid.App..ctor() in C:\Users\hmurphy\Documents\Pittsh\Projects\mouse_droid\MouseDroid\App.xaml.cs:line 17
   at MouseDroid.UWP.MainPage..ctor() in C:\Users\hmurphy\Documents\Pittsh\Projects\mouse_droid\MouseDroid.UWP\MainPage.xaml.cs:line 24
   at MouseDroid.UWP.MouseDroid_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage() in C:\Users\hmurphy\Documents\Pittsh\Projects\mouse_droid\MouseDroid.UWP\obj\x64\Debug\XamlTypeInfo.g.cs:line 207
   at MouseDroid.UWP.MouseDroid_UWP_XamlTypeInfo.XamlUserType.ActivateInstance() in C:\Users\hmurphy\Documents\Pittsh\Projects\mouse_droid\MouseDroid.UWP\obj\x64\Debug\XamlTypeInfo.g.cs:line 429

Inner Exception 1:
DllNotFoundException: Unable to load DLL 'realm-wrappers': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

这发生在我的MainPageViewModel 内部,调用GetInstance

public class MainPageViewModel
{
    public IEnumerable<Package> Packages { get; private set; }

    public INavigation Navigation { get; set; }

    private Realm _realm;

    public MainPageViewModel() 
    {
        _realm = Realm.GetInstance();

        Packages = _realm.All<Package>();
    }
}

我使用的是 1.5.0。根据commit 的说法,这似乎不是问题。

我的配置是为 UWP 使用 x86。 UWP 设置为构建和部署。我已经重新构建了我的解决方案,以防FodyWeaver 对象没有正确生成。我错过了什么吗?

【问题讨论】:

    标签: visual-studio xamarin uwp xamarin.forms realm


    【解决方案1】:

    17 年 10 月更新:从 Realm 2.0.0 开始,完全支持同步 UWP,升级到最新版本应该可以解决问题。


    对于想要坚持使用 pre-2.0 的人,这是以前的答案:

    您应该删除 UWP 上的 Realm 包,而改用 Realm.Database 一个。您收到此错误的原因是 Realm 包包含与同步相关的 API,即 not yet supported on UWP/Windows

    【讨论】:

    • 感谢上帝。我以为我要疯了
    • 虽然现在我收到以下错误 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    • 没关系,发生这种情况是因为我在我的 xaml 中摆弄 {x:Bind}。不像我想象的那样与 Realm 相关
    猜你喜欢
    • 1970-01-01
    • 2017-02-15
    • 1970-01-01
    • 2017-06-26
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多