Xamarin.Forms UWP应用程序在运行时因.net本机工具链失败,但可以正常运行

卡灵顿

我有一个Xamarin.Forms UWP应用(Xamarin.Forms v3.4.0.1008975,UWP目标/最小版本16299,VS 2017 15.9.11)。在没有.net本机工具链的情况下进行编译时,它将正确构建并运行。使用.net本机工具链进行编译时,它可以正常运行,但在运行时会失败。这是一个问题,因为我无法将应用程序发布到Windows应用商店。这个应用程式先前(〜10个月前)已发布到商店,并且运作正常。从那时起,已经进行了广泛的大修,其中包括XF,Prism,sqlite软件包的更新版本,以及许多其他更改中添加的其他几个软件包,因此几乎不可能找出可能导致更改的原因。

通过设法获取Rg.Plugins.Popup和Xam.Plugin.Iconize.FontAwesome软件包的一些初始问题,我获得了它们的程序集列表,并将它们传递到Xamarin.Forms.Forms.Init(e, assemblies);UWP项目的App.xaml.cs中。此修复了我的应用程序中的弹出窗口和字体图标的崩溃/显示问题。

当应用程序启动时,我在窗体FileNotFoundExceptionXamarin.Forms.Forms.Init(...)调用中看到一些已处理的内容Cannot load assembly 'clrcompression'. No metadata found for this assembly.缺少的程序集是:

  • 压缩
  • e_sqlite3
  • libEGL
  • libGLESv2
  • libSkiaSharp
  • SkiaSharp.Views.Interop.UWP
  • sqlite3

如上所述,这些错误已得到处理,仅在调试时可见。我没有看到任何明确的证据表明这些错误是一个问题,因为该应用程序肯定从Sqlite读取了一些数据而没有错误,并且我看到使用SkiaSharp正确绘制的图像。

但是,当我执行某些使应用程序崩溃的操作时,我遇到了其他运行时错误。例如Unhandled exception at 0x05F8F74C (SharedLibrary.dll) in MyApp.UWP.exe: 0x00001007. occurred如果我在线程窗口中查看,会得到更多信息:

Not Flagged >   13884   0   Worker Thread   <No Name>   
System.Private.SharedLibrary.Interop.Generated.dll!__Interop.api_ms_win_core_kernel32_legacy_l1_1_0_dll.PInvoke_RaiseFailFastException
System.Private.SharedLibrary.Interop.Generated.dll!__Interop.api_ms_win_core_kernel32_legacy_l1_1_0_dll.PInvoke_RaiseFailFastException(Interop._EXCEPTION_RECORD* pExceptionRecord, System.IntPtr pContextRecord, uint dwFlags)
System.Private.CoreLib.dll!Interop.mincore.PInvoke_RaiseFailFastException(Interop._EXCEPTION_RECORD* pExceptionRecord, System.IntPtr pContextRecord, uint dwFlags)
System.Private.CoreLib.dll!Interop.mincore.RaiseFailFastException(uint faultCode, System.IntPtr pExAddress, System.IntPtr pExContext) Line 122
System.Private.CoreLib.dll!System.RuntimeExceptionHelpers.FailFast(string message, System.Exception exception, System.RuntimeExceptionHelpers.RhFailFastReason reason, System.IntPtr pExAddress, System.IntPtr pExContext) Line 237
System.Private.CoreLib.dll!System.RuntimeExceptionHelpers.RuntimeFailFast(System.RuntimeExceptionHelpers.RhFailFastReason reason, System.Exception exception, System.IntPtr pExAddress, System.IntPtr pExContext) Line 200
[External Code]
System.Private.CoreLib.dll!Internal.Runtime.Augments.RuntimeAugments.RunFunctionWithConservativelyReportedBufferInternal<Internal.Runtime.TypeLoader.CallConversionParameters>(int cbBuffer, System.IntPtr pfnTargetToInvoke, ref Internal.Runtime.TypeLoader.CallConversionParameters context, ref System.Runtime.RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
System.Private.CoreLib.dll!Internal.Runtime.Augments.RuntimeAugments.RunFunctionWithConservativelyReportedBuffer<Internal.Runtime.TypeLoader.CallConversionParameters>(int cbBuffer, System.IntPtr pfnTargetToInvoke, ref Internal.Runtime.TypeLoader.CallConversionParameters context)
System.Private.TypeLoader.dll!Internal.Runtime.TypeLoader.CallConverterThunk.CallConversionThunk(System.IntPtr callerTransitionBlockParam, System.IntPtr callConversionId)
[External Code]
Prism.dll!Prism.Mvvm.BindableBase.SetProperty<int?>(ref int? storage, int? value, string propertyName)
[External Code]
System.Private.CoreLib.dll!Internal.Runtime.Augments.RuntimeAugments.CallDescrWorker(System.IntPtr callDescr) Line 970
System.Private.TypeLoader.dll!Internal.Runtime.TypeLoader.CallConverterThunk.InvokeTarget(void* allocatedStackBuffer, ref Internal.Runtime.TypeLoader.CallConversionParameters conversionParams)
System.Private.CoreLib.dll!Internal.Runtime.Augments.RuntimeAugments.RunFunctionWithConservativelyReportedBufferInternal<Internal.Runtime.TypeLoader.CallConversionParameters>(int cbBuffer, System.IntPtr pfnTargetToInvoke, ref Internal.Runtime.TypeLoader.CallConversionParameters context, ref System.Runtime.RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
System.Private.CoreLib.dll!Internal.Runtime.Augments.RuntimeAugments.RunFunctionWithConservativelyReportedBuffer<Internal.Runtime.TypeLoader.CallConversionParameters>(int cbBuffer, System.IntPtr pfnTargetToInvoke, ref Internal.Runtime.TypeLoader.CallConversionParameters context)
System.Private.TypeLoader.dll!Internal.Runtime.TypeLoader.CallConverterThunk.CallConversionThunk(System.IntPtr callerTransitionBlockParam, System.IntPtr callConversionId)
[External Code]
MyApp.dll!MyApp.ViewModels.AppLevel.AppStatusViewModel.CurrentSynchroniseJobTasksCount.set(int? value) Line 415
MyApp.dll!MyApp.ViewModels.AppLevel.AppStatusViewModel.HandleDataSyncStartEvent(string payload) Line 287
[External Code]
MyApp.dll!MyApp.Services.Synchronisation.DataSyncCoordinator.DoSynchronisationJob() Line 84
MyApp.dll!MyApp.Services.Synchronisation.DataSyncCoordinator.AttemptSynchronisationTask(MyApp.Services.Synchronisation.IDatabaseSyncJob job) Line 74
MyApp.dll!MyApp.Services.Synchronisation.DataSyncService.DeleteLocalData(string dbResetKey) Line 29
MyApp.dll!MyApp.ViewModels.ClearLocalDataPopupViewModel.Submit() Line 66
[Resuming Async Method]
[External Code]

不幸的是,尽管这告诉了我问题出在哪里,但并没有为我提供任何有关为什么发生以及如何解决的线索。在这种情况下,似乎无法在视图模型上设置属性,但是即使到了代码中的这一点,它也必须在其他地方成功完成此操作。我想我真的在寻找有关如何调查/获取更多信息的指南,因为如果没有一些源代码(我无法真正提供),将很难解决特定问题。我曾尝试过在关闭优化的情况下进行调试,这通常是建议的,但没有提供比我在此处发布的更多的信息。

我还担心,即使我找出为什么会发生此特殊异常并进行修复,也可能会导致应用程序中只有使用.net本机工具链时才会出现更多问题。有什么工具可以帮助我吗?

卡灵顿

因此,事实证明这是Prism(7.0.0.396)和.net本机的问题。int?使用BindableBase.SetProperty.net本机工具链进行编译时,看起来好像使用失败将绑定属性与可为null的类型(在这种情况下)结合使用以下内容似乎可以解决此问题:

public class BindableBaseWithFix : BindableBase
{
    protected virtual bool SetProperty<T>(ref T? storage, T? value, [CallerMemberName] string propertyName = null)
        where T : struct
    {
        if (EqualityComparer<T?>.Default.Equals(storage, value))
            return false;
        storage = value;
        RaisePropertyChanged(propertyName);
        return true;
    }
} 

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法在Xamarin Forms-> Android上的运行时更改应用程序语言

Xamarin Forms按钮单击事件在运行时崩溃

Xamarin.Forms在运行时加载XAML视图

Xamarin.Forms UWP - 请求启用应用程序以在启动时运行

为什么Visual Studio 2017的新AutoScale支持在运行时调整我的Forms应用程序的大小?

Xamarin Forms iOS-当前上下文中不存在运行时

Xamarin.Forms在运行时更改UI语言(XAML)

在运行时绑定 Xamarin Forms 中标签的 FormattedString 跨度

如何在运行时xamarin.forms检查APK签名

在运行时更新UWP应用程序的任务栏图标

Xamarin.Droid应用程序在选中的“共享运行时选项”时崩溃

Xcode 7 Beta Swift应用程序在运行时因EXC_BAD_ACCESS错误而崩溃

在运行时检测 MSIX 打包的应用程序

在运行时更改Polymer应用程序的主题

在运行时更改应用程序主题

在运行时更改应用程序MainForm

在运行时更改应用程序语言

在运行时设计 Angular 应用程序的样式

Web应用程序:在运行时删除文件

从正在运行的 iOS / macOS 应用程序实例(Xamarin Forms)获取资源文件夹路径的正确方法是什么

运行Xamarin.Forms应用程序时如何查找Android和iOS版本?

Xamarin Forms:在 iPad 上运行应用程序时出现 UI 问题

无法确定Xamarin Forms应用程序是否正在模拟器中或设备上运行

Xamarin.Forms应用程序将无法在Android设备上运行

为什么Xamarin.Forms应用程序不能在Chromebook上运行?

即使关闭应用程序,Android服务也会从Xamarin Forms Project运行代码吗?

运行 xamarin.forms 应用程序时未将对象引用设置为对象的实例

为什么UWP应用程序中的表单/页面在运行时被截断(不反映设计时间的大小)?

Xamarin Forms应用由于LiveXAML失败