Mvvm light 内置.Net本机时出现UWP应用程序错误

Mvvm light 内置.Net本机时出现UWP应用程序错误,mvvm-light,win-universal-app,Mvvm Light,Win Universal App,我们有一个Windows 8.1应用程序,已经转换为Windows 10 UWP应用程序。该应用程序在调试中运行良好,但在版本(.Net Native)中运行时,我们在加载应用程序时遇到运行时错误。根本不清楚是什么导致了这个错误。该错误发生在App.xaml.cs中的OnLaunched事件中,其中一些数据正在初始化。错误: 中发生System.NullReferenceException类型的异常 System.Private.CoreLib.dll 其他信息:Arg_NullReferenc

我们有一个Windows 8.1应用程序,已经转换为Windows 10 UWP应用程序。该应用程序在调试中运行良好,但在版本(.Net Native)中运行时,我们在加载应用程序时遇到运行时错误。根本不清楚是什么导致了这个错误。该错误发生在App.xaml.cs中的OnLaunched事件中,其中一些数据正在初始化。错误:

中发生System.NullReferenceException类型的异常 System.Private.CoreLib.dll

其他信息:Arg_NullReferenceException

我们正在使用最新版本的MVVM Light


我知道这并不是很多信息,但这确实是我们现在所拥有的所有信息,我们非常困惑。有没有人见过这样的问题,或者知道从哪里开始追踪

如果,您仍在使用SQLite或任何引用。
请右键单击您的
项目=>Add=>Reference=>确保已选中Nuget的DLL


请检查此解决方案。

如果您仍在使用SQLite或任何引用。
请右键单击您的
项目=>Add=>Reference=>确保已选中Nuget的DLL


请检查此解决方案。

我有一个确切的问题,我将一个8.1应用程序转换为UWP。通过在
Properties
文件夹中包含一个名为
Default.rd.xml
的文件,解决了这个问题。我使用的迁移指南中没有提到这一点

不包括它意味着一些非常常见的编码模式,如反射将无法工作,这包括在imported.dll中

基本
Default.rd.xml
文件如下所示

<!--
    This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
    developers. However, you can modify these parameters to modify the behavior of the .NET Native
    optimizer.

    Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919

    To fully enable reflection for App1.MyClass and all of its public/private members
    <Type Name="App1.MyClass" Dynamic="Required All"/>

    To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
    <TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />

    Using the Namespace directive to apply reflection policy to all the types in a particular namespace
    <Namespace Name="DataClasses.ViewModels" Serialize="All" />
-->

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <!--
      An Assembly element with Name="*Application*" applies to all assemblies in
      the application package. The asterisks are not wildcards.
    -->
    <Assembly Name="*Application*" Dynamic="Required All" />


    <!-- Add your application specific runtime directives here. -->


  </Application>
</Directives>


如果这不起作用,那么尝试创建一个新的空UWP项目以获取文件的最新格式。

我遇到了一个确切的问题,我将一个8.1应用程序转换为UWP。通过在
Properties
文件夹中包含一个名为
Default.rd.xml
的文件,解决了这个问题。我使用的迁移指南中没有提到这一点

不包括它意味着一些非常常见的编码模式,如反射将无法工作,这包括在imported.dll中

基本
Default.rd.xml
文件如下所示

<!--
    This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
    developers. However, you can modify these parameters to modify the behavior of the .NET Native
    optimizer.

    Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919

    To fully enable reflection for App1.MyClass and all of its public/private members
    <Type Name="App1.MyClass" Dynamic="Required All"/>

    To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
    <TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />

    Using the Namespace directive to apply reflection policy to all the types in a particular namespace
    <Namespace Name="DataClasses.ViewModels" Serialize="All" />
-->

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <!--
      An Assembly element with Name="*Application*" applies to all assemblies in
      the application package. The asterisks are not wildcards.
    -->
    <Assembly Name="*Application*" Dynamic="Required All" />


    <!-- Add your application specific runtime directives here. -->


  </Application>
</Directives>


如果这不起作用,请尝试创建一个新的空UWP项目,以获取文件的最新格式。

您需要知道.Net Native将尝试优化引用。因此,它认为不需要的任何类型都将被省略。因此,如果代码或任何引用的库中存在任何反射,则需要显式地将其添加回rd.xml文件中。更多信息同样的问题,我发现错误是由第一次调用Messenger引起的。默认值,Register方法,我尝试为此添加一个指令,但是仍然存在错误:
有任何建议@depchie?抱歉,我不是如何处理.net本机错误的专家:/n您需要知道.net本机将尝试优化引用。因此,它认为不需要的任何类型都将被省略。因此,如果代码或任何引用的库中存在任何反射,则需要显式地将其添加回rd.xml文件中。更多信息同样的问题,我发现错误是由第一次调用Messenger引起的。默认情况下,注册方法,我试图为此添加一个指令,但仍然存在错误:
有任何建议@Depechie?抱歉,我不是如何处理.net本机错误的专家:/