我有一个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]
不幸的是,尽管这告诉了我问题出在哪里,但并没有为我提供任何有关为什么发生以及如何解决的线索。在这种情况下,似乎无法在视图模型上设置属性,但是即使到了代码中的这一点,它也必须在其他地方成功完成此操作。我想我真的在寻找有关如何调查/获取更多信息的指南,因为如果没有一些源代码(我无法真正提供),将很难解决特定问题。我曾尝试过在关闭优化的情况下进行调试,这通常是建议的,但没有提供比我在此处发布的更多的信息。
我还担心,即使我找出为什么会发生此特殊异常并进行修复,也可能会导致应用程序中只有使用.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] 删除。
我来说两句