rca*_*ton 5 c# .net-native xamarin.uwp
我有一个 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 中,成功解决了这些包的一些初始问题。这修复了我的应用程序中弹出窗口和字体图标的崩溃/显示问题。
当应用程序启动时,我看到几个FileNotFoundException在Xamarin.Forms.Forms.Init(...)表单调用中得到处理Cannot load assembly 'clrcompression'. No metadata found for this assembly.。缺少的程序集是:
如前所述,这些错误已被处理并且仅在调试时可见。我还没有看到任何明确的证据表明这些错误是一个问题,因为应用程序肯定从 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]
Run Code Online (Sandbox Code Playgroud)
不幸的是,虽然这告诉我问题发生在哪里,但它没有给我任何关于为什么会发生以及如何解决它的线索。在这种情况下,它似乎无法在视图模型上设置属性,但即使要在代码中达到这一点,它也必须在其他地方成功完成此操作。我想我真的在寻找有关如何调查此问题/获取更多信息的指导,因为如果没有一些源代码(我无法真正提供),将很难解决特定问题。我尝试过在关闭优化的情况下进行调试,这通常是建议的,但它没有提供比我在这里发布的更多信息。
我还担心,即使我找出发生此特定异常的原因并修复它,应用程序中可能还会出现更多问题,这些问题仅在使用 .net 本机工具链时出现。我可以使用任何工具来帮助解决这个问题吗?
所以这是 Prism (7.0.0.396) 和 .net 本机的问题。它看起来像是使用.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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
638 次 |
| 最近记录: |