0

我正在使用热重启直接调试我的 iPhone。该应用程序仅在使用云解决方案的模拟器中使用热重启时崩溃,该应用程序运行良好。

我有一个 .Resx 文件 AppResources 并且我正在使用 Xamarin Community Toolkit 提供的翻译扩展,以便能够使用我的 .Resx 中的密钥我使用了生成密钥的文本模板及其名称,以便能够像这样调用它们:

<Label Text="{toolkit:Translate Text={Static t4:AppResources.Key}}" FontSize="Large" HorizontalOptions="CenterAndExpand"/>
<Label Text="{Static t4:AppResources.Key}" FontSize="Large" HorizontalOptions="CenterAndExpand"/>

该应用程序崩溃了我尝试使用的一个

静态 t4:AppResources.Key

我不知道我做错了什么。我上传了解决方案 GitHub:GitHub 链接

是否有解决该问题的方法,或者可以通过其他方式从 .Resx 文件中获取密钥。

谢谢您的帮助

这是崩溃报告。

======================================== 原生崩溃报告 ======== ================================ 在执行本机代码时获得了 segv。这通常表示单声道运行时或您的应用程序使用的本机库之一中存在致命错误。

==========================================本
机堆栈跟踪:====== ==================================================== =========

0x102370120 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_dump_native_crash_info

0x102366cbc - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_handle_native_crash 0x102373a60 - /private/var/containers/Bundle/Application/95CE47E -9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_sigsegv_signal_handler_debug 0x1d06bc29c - /usr/lib/system/libsystem_platform.dylib:0x102514ec4 - /private/var/containers/Bundle/Application/95CE4E7 9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_exec_method_full

0x102514ec4 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_exec_method_full 0x102514ec4 - /private/var/containers/Bundle/Application/95CE4E70 -9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_exec_method_full 0x10250feb0 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest。 /Xamarin.PreBuilt.iOS:interp_runtime_invoke 0x102376d3c - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_jit_runtime_invoke 0x10242525 /containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_runtime_invoke_checked 0x102428728-/private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_runtime_invoke 0x102508ccc-/Bundle/Application/var/containers/ /95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:xamarin_invoke_trampoline 0x10250e0cc - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0FileTest.iOS01 .app/Xamarin.PreBuilt.iOS:xamarin_arch_trampoline 0x10250ec70 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:xamarin_arm64_common_trampoline 0x /Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x1874d123c - /System/Library/PrivateFrameworks/UIKitCore。框架/UIKitCore :0x1874d7388 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore :0x186b2ac98 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore :0x187093f58 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore :_ctionUIScenePerformA 0x186b2b830-/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x186b2b2f0-/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x186b2b640-/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x186b2ae7c /Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x186b333c0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x186fa1970 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x1870acd68 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : _UISceneSettingsDiffActionPerformChangesWithTransitionContext 0x186b330b8 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 0x18695afa0 - /System/Library/Private2CoreFrameworks/0UIKitCore.framework:x95999 /Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x18695abc8 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x1874d5528 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x186fcafd0 - /System/Library/PrivateFrameworks/ UIKitCore.framework/UIKitCore:0x1940775d8 - /System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices:0x1940a2d44 - /System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices:0x1940866a4 - /System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices:0x1940a2a0c - /System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices:0x1846d281c - /usr/lib/system/libdispatch.dylib:0x1846d630c -/ system/libdispatch.dylib:0x1940cafa0-/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices:0x1940cac30-/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices:0x1940cb184-/System/Library/PrivateFrameworks/F rontBoardServices。 FrontBoardServices:0x184a5f9e8 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:0x184a5f8e4 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:0x184a5ebe8 - /System/Library/Frameworks/CoreFoundation。框架/CoreFoundation:0x184a58bc8 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:0x184a58360 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:CFRunLoopRunSpecific 0x19c096734 - /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices: GSEventRunModal 0x1874d3584 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:0x1874d8df4 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:UIApplicationMain 0x10251c8fc - /private/var/containers/Bundle/Application/95CE4E70-9227-43D -A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:do_icall 0x10251b010 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt .iOS:do_icall_wrapper 0x102511a8c - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_exec_method_full 0x10250feb0 - /private/var/containers/Bundle/Application/ 95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_runtime_invoke 0x102376d3c - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-TF4AD08B0B10.iOS.FileICC9 app/Xamarin.PreBuilt.iOS:mono_jit_runtime_invoke 0x1024252c0-/private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_runtime_invoke_checked 0x1024 var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_runtime_try_invoke_array 0x1023d39c4-/private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:ves_icall_InternalInvoke 0x1023e3b68-/Application/var 95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:ves_icall_InternalInvoke_raw 0x10251c8fc - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-ADICCphoneTest.iOS.B090/ app/Xamarin.PreBuilt.iOS:do_icall 0x10251b010-/private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:do_icall_wrapper 0x102511a8c-/private/ var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_exec_method_full 0x10250feb0 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:interp_runtime_invoke 0x102376d3c - /private/var//containers/Bundle/Application 95CE4E70-9227-4 3D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_jit_runtime_invoke 0x1024252c0 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-ACC04D-ADIFilephoneTest1.iOS1 .app/Xamarin.PreBuilt.iOS:mono_runtime_invoke_checked 0x10242a564-/private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_runtime_35_main_checked-0x8f1 /var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:mono_jit_exec 0x10250d984 - /private/var/containers/Bundle/Application/95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:xamarin_main 0x102323c34 - /private/var/containers/Bundle/Application/ 95CE4E70-9227-43D7-A04D-AD08B0B10CC9/TF4FileIphoneTest.iOS.app/Xamarin.PreBuilt.iOS:主 0x184714cf8 - /usr/lib/system/libdyld.dylib:

==================================================== ========= ====== 基本故障地址报告 ================================ ================================== 本机指令指针周围的内存(0x102517878):0x102517868 20 01 1f d6 18 0b 00 91 48 83 5f f8 08 10 00 b4 .......H. ..... 0x102517878 08 11 40 b9 48 83 1f b8 08 03 40 79 a9 0f 00 b0 ..@.H .....@y.... 0x102517888 29 a1 33 91 28 79 68 f8 00 01 1f d6 48 83 5f f8 ).3.(yh.....H. . 0x102517898 e8 0e 00 b4 08 01 40 f9 08 01 40 f9 08 69 40 39 ......@...@..i @9

========================================== 托管堆栈跟踪:====== =================================== 在 UIKit.UIApplication:UIApplicationMain <0x000b8> 在 UIKit 的 <0xffffffff> UIApplication:Main <0x00020> at UIKit.UIApplication:Main <0x00038> at TF4FileIphoneTest.iOS.Application:Main <0x00012> at :runtime_invoke_direct_void_string[] <0x00092> at <0xffffffff> at System.Reflection.RuntimeMethodInfo:InternalInvoke <0x00030> at System.Reflection.RuntimeMethodInfo:Invoke <0x000fc> at System.Reflection.MethodBase:Invoke <0x0001a> at Xamarin.PreBuilt.iOS.Applications:Main <0x00254> at :runtime_invoke_direct_void_string[] <0x00092>

该应用程序已终止。

4

2 回答 2

0

不支持静态 iOS 库和框架,如果您的应用尝试加载这些库和框架,您可能会看到运行时错误或崩溃。使用 HOTRESTART 预处理器符号来防止执行此代码。支持动态 iOS 库。详情请参考(https://docs.microsoft.com/en-us/xamarin/xamarin-forms/deploy-test/hot-restart

于 2021-08-02T08:06:59.427 回答
0

我通过更改密钥的生成方式解决了这个问题。

把它从

    internal static string <#= entry.Name #>
{
    get { return nameof(<#= entry.Name #>); }
}

internal static string <#= entry.Name #> = "<#= entry.Name #>";

该应用程序停止崩溃

于 2021-08-04T15:26:02.753 回答