Xamarin.Forms UWP应用程序在运行时使用.net本机工具链失败,但工作原理不然

问题描述 投票:0回答:1

我有一个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软件包的一些初始问题,获取它们的程序集列表并将它们传递到UWP项目中的App.xaml.cs中的Xamarin.Forms.Forms.Init(e, assemblies);。这修复了我的应用程序中弹出窗口和字体图标的崩溃/显示问题。

当应用程序启动时,我在FileNotFoundException形式的Xamarin.Forms.Forms.Init(...)调用中看到几个处理Cannot load assembly 'clrcompression'. No metadata found for this assembly.。缺少的程序集是:

  • clrcompression
  • 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]

不幸的是,虽然这告诉我问题发生在哪里但它没有给我任何关于它为什么会发生以及如何解决它的线索。在这种情况下,似乎无法在viewmodel上设置属性,但是甚至在代码中达到这一点,它必须在其他地方成功完成此操作。我想我真的在寻找如何调查这个/得到更多信息的指导,因为如果没有一些源代码(我无法真正提供),很难解决具体问题。我已经尝试过关闭优化的调试,这通常是建议但是没有提供比我在这里发布的更多信息。

我也担心,即使我发现为什么会发生这种特殊异常并修复它,应用程序中可能会出现更多问题,只有在使用.net本机工具链时才会出现。我可以使用任何工具来帮助解决这个问题吗?

c# xamarin.uwp .net-native
1个回答
1
投票

所以这被证明是Prism(7.0.0.396)和.net native的问题。当使用.net本机工具链编译时,使用int?看起来像绑定属性具有可空类型(在本例中为BindableBase.SetProperty)。以下似乎解决了这个问题:

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;
    }
} 
© www.soinside.com 2019 - 2024. All rights reserved.