簡體   English   中英

Xamarin.Forms UWP應用程序在運行時因.net本機工具鏈而失敗,但可以正常運行

[英]Xamarin.Forms UWP app failing at run time with .net native tool chain but works otherwise

我有一個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中。 此修復了我的應用程序中的彈出窗口和字體圖標的崩潰/顯示問題。

當應用啟動時,我在Xamarin.Forms.Forms.Init(...)調用中看到幾個已處理的FileNotFoundException形式, Cannot load assembly 'clrcompression'. No metadata found for this assembly. 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 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本機的問題。 使用.net本機工具鏈編譯時,使用BindableBase.SetProperty具有可空類型(在這種情況下為int? )的屬性似乎失敗。 以下內容似乎可以解決此問題:

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;
    }
} 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM