当我尝试上传 Microsoft Store 时,UWP/Xamarin 在提交测试中崩溃
UWP / Xamarin crash in submission tests when I try to upload a microsoft store
我正在使用 Xamarin Forms 开发一个带有 SignalR 的消息发送应用程序,我已经在本地和 Android 上测试了无数次并且它工作正常没有崩溃,但是当他们进行测试以将其上传到微软商店报告我的应用程序崩溃了。
根据应用中心,应用程序在尝试通过 SignalR 发送消息时崩溃,这是错误:
d__46.MoveNext ()
+ 0x14b
System.Reflection.MissingMetadataException:无法执行此操作,因为出于性能原因删除了以下对象的元数据:\n\n EETypeRva:0x0035FCD8\n\n无更多信息可用。在调试模式下重建以获得更好的信息。\n\n
System.Reflection.Runtime.TypeInfos
RuntimeNoMetadataNamedTypeInfo.get_InternalFullNameOfAssembly () f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\TypeInfos\RuntimeBlockedTypeInfo.cs at 240:17
System.Text.Json
JsonPropertyInfo.Initialize (Type, Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x11f
System.Text.Json
JsonPropertyInfoCommon`4.Initialize (Type, Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x:59
System.Text.Json
JsonClassInfo.CreateProperty (Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x2f:2
System.Text.Json
JsonClassInfo.AddProperty (Type, PropertyInfo, Type, JsonSerializerOptions) + 0x9e
System.Text.Json
JsonClassInfo.AddPolicyProperty (Type, JsonSerializerOptions) + 0x2f
System.Text.Json.JsonClassInfo
+ 0xdd:1
System.Text.Json
JsonSerializerOptions.GetOrAddClass (Type) + 0x:71
System.Text.Json
WriteStackFrame.Initialize (Type, JsonSerializerOptions) + 0x:13
System.Text.Json
JsonSerializer.WriteCore (Utf8JsonWriter, Object, Type, JsonSerializerOptions) + 0x8d
System.Text.Json
JsonSerializer.WriteValueCore (Utf8JsonWriter, Object, Type, JsonSerializerOptions) + 0x3e
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteArguments (Object[], Utf8JsonWriter) + 0x1ef
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteStreamInvocationMessage (StreamInvocationMessage, Utf8JsonWriter) + 0x:65
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteMessageCore (HubMessage, IBufferWriter`1) + 0x55d
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteMessage (HubMessage, IBufferWriter`1) + 0xc
Microsoft.AspNetCore.SignalR.Client.HubConnection
<SendHubMessage>d__72.MoveNext () + 0x7f
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Runtime.CompilerServices
TaskAwaiter.GetResult () + 0xb
Microsoft.AspNetCore.SignalR.Client.HubConnection
<InvokeCore>d__70.MoveNext () + 0x:194
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
Microsoft.AspNetCore.SignalR.Client.HubConnection
<InvokeCoreAsyncCore>d__69.MoveNext () + 0x:335
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Threading.Tasks
ForceAsyncAwaiter`1.GetResult () + 0x:18
Microsoft.AspNetCore.SignalR.Client.HubConnection
<InvokeCoreAsync>d__56.MoveNext () + 0x:105
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Runtime.CompilerServices
TaskAwaiter.GetResult () + 0xb
Chat.Shared.Core.ChatService
<SendPrivateMessageAsync>d__46.MoveNext () + 0x14b
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Runtime.CompilerServices
TaskAwaiter.GetResult () + 0xb
MyClinicalApp.ViewModels.ChatViewModel.<>c__DisplayClass39_1
<<SendMessage>b__1>d.MoveNext () + 0x:137
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices.AsyncMethodBuilderCore
<>c.<ThrowAsync>b__7_0 (Object) + 0x1e
System
Action`1.Invoke (T) + 0x:28
System.Threading.WinRTSynchronizationContext
Invoker.InvokeCore () + 0x:33
System.Runtime.InteropServices
McgMarshal.ThrowOnExternalCallFailed (Int32, RuntimeTypeHandle) + 0x:21
__Interop
ComCallHelpers.Call (__ComObject, RuntimeTypeHandle, Int32) + 0xb:8
__Interop
ForwardComStubs.Stub_15[TThis] (__ComObject, Int32) + 0x:24
Microsoft.AppCenter.Utils
ApplicationLifecycleHelper.<ctor>b__17_1 (Object, UnhandledErrorDetectedEventArgs) + 0x3d
如果有人可以给我任何关于如何确定错误的提示或建议。谢谢。
P.S。我也尝试过上传调试符号,但我认为应用中心页面有错误或者我可能做错了什么,问题是在尝试上传大约 20 分钟后页面被清理并且没有上传任何东西,这个过程我会尝试 7 次,但我从未成功上传 .appxsym
您看到的问题是由 .NET Native 工具链剥离代码以使程序集更小更快引起的。不幸的是,.NET Native 不够智能,无法理解何时需要反映类型,并且有时可能会删除您实际上需要的元数据。
调试这有点复杂,因为您需要尝试确切需要和缺少元数据的类型,并在 Default.rd.xml
文件中将此类型标记为必需,您可以在 Properties
UWP 项目中的文件夹。网上有个很有用的.NET Native MissingMetadataException troubleshooter。它旨在为您自动生成正确的 rd.xml 语法。您唯一需要做的就是填写 type/namespace 名称并指定类型的反映方式。
要找到问题的确切根源,请将构建配置切换到 Visual Studio 中的 Release
,然后将应用程序切换到 运行 并观察它在哪个点崩溃。有时它也有助于注释和取消注释代码以找出它发生的确切位置。在你的情况下,我怀疑这是由于 JSON 序列化和反序列化,这经常发生,因为类型仅用于此唯一目的,属性 "appear" 好像没有在任何地方引用。
感谢 Martin Zikmund 帮助我理解问题。
为了发现错误的根源,必须在启用 .NET Native 的情况下在 DEBUG 配置中进行编译(项目属性 > 生成 > 启用“.NET Native 工具链”复选框)。通过这种方式,我能够确定哪个是 MissingMetadataException,从而能够正确地形成 rd.xml 文件。
在我的例子中,它被更正为:
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterString" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterBoolean" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterObject" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterByteArray" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterDateTime" Dynamic="Required All" />
</Application>
</Directives>
还要感谢 Jarvan y Matthew Whilden 抽出时间帮我解决问题。
我正在使用 Xamarin Forms 开发一个带有 SignalR 的消息发送应用程序,我已经在本地和 Android 上测试了无数次并且它工作正常没有崩溃,但是当他们进行测试以将其上传到微软商店报告我的应用程序崩溃了。
根据应用中心,应用程序在尝试通过 SignalR 发送消息时崩溃,这是错误:
System.Reflection.Runtime.TypeInfos
RuntimeNoMetadataNamedTypeInfo.get_InternalFullNameOfAssembly () f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\TypeInfos\RuntimeBlockedTypeInfo.cs at 240:17
System.Text.Json
JsonPropertyInfo.Initialize (Type, Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x11f
System.Text.Json
JsonPropertyInfoCommon`4.Initialize (Type, Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x:59
System.Text.Json
JsonClassInfo.CreateProperty (Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x2f:2
System.Text.Json
JsonClassInfo.AddProperty (Type, PropertyInfo, Type, JsonSerializerOptions) + 0x9e
System.Text.Json
JsonClassInfo.AddPolicyProperty (Type, JsonSerializerOptions) + 0x2f
System.Text.Json.JsonClassInfo
+ 0xdd:1
System.Text.Json
JsonSerializerOptions.GetOrAddClass (Type) + 0x:71
System.Text.Json
WriteStackFrame.Initialize (Type, JsonSerializerOptions) + 0x:13
System.Text.Json
JsonSerializer.WriteCore (Utf8JsonWriter, Object, Type, JsonSerializerOptions) + 0x8d
System.Text.Json
JsonSerializer.WriteValueCore (Utf8JsonWriter, Object, Type, JsonSerializerOptions) + 0x3e
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteArguments (Object[], Utf8JsonWriter) + 0x1ef
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteStreamInvocationMessage (StreamInvocationMessage, Utf8JsonWriter) + 0x:65
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteMessageCore (HubMessage, IBufferWriter`1) + 0x55d
Microsoft.AspNetCore.SignalR.Protocol
JsonHubProtocol.WriteMessage (HubMessage, IBufferWriter`1) + 0xc
Microsoft.AspNetCore.SignalR.Client.HubConnection
<SendHubMessage>d__72.MoveNext () + 0x7f
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Runtime.CompilerServices
TaskAwaiter.GetResult () + 0xb
Microsoft.AspNetCore.SignalR.Client.HubConnection
<InvokeCore>d__70.MoveNext () + 0x:194
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
Microsoft.AspNetCore.SignalR.Client.HubConnection
<InvokeCoreAsyncCore>d__69.MoveNext () + 0x:335
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Threading.Tasks
ForceAsyncAwaiter`1.GetResult () + 0x:18
Microsoft.AspNetCore.SignalR.Client.HubConnection
<InvokeCoreAsync>d__56.MoveNext () + 0x:105
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Runtime.CompilerServices
TaskAwaiter.GetResult () + 0xb
Chat.Shared.Core.ChatService
<SendPrivateMessageAsync>d__46.MoveNext () + 0x14b
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices
TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70
System.Runtime.CompilerServices
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38
System.Runtime.CompilerServices
TaskAwaiter.ValidateEnd (Task) + 0x:17
System.Runtime.CompilerServices
TaskAwaiter.GetResult () + 0xb
MyClinicalApp.ViewModels.ChatViewModel.<>c__DisplayClass39_1
<<SendMessage>b__1>d.MoveNext () + 0x:137
System.Runtime.ExceptionServices
ExceptionDispatchInfo.Throw () + 0x:21
System.Runtime.CompilerServices.AsyncMethodBuilderCore
<>c.<ThrowAsync>b__7_0 (Object) + 0x1e
System
Action`1.Invoke (T) + 0x:28
System.Threading.WinRTSynchronizationContext
Invoker.InvokeCore () + 0x:33
System.Runtime.InteropServices
McgMarshal.ThrowOnExternalCallFailed (Int32, RuntimeTypeHandle) + 0x:21
__Interop
ComCallHelpers.Call (__ComObject, RuntimeTypeHandle, Int32) + 0xb:8
__Interop
ForwardComStubs.Stub_15[TThis] (__ComObject, Int32) + 0x:24
Microsoft.AppCenter.Utils
ApplicationLifecycleHelper.<ctor>b__17_1 (Object, UnhandledErrorDetectedEventArgs) + 0x3d
如果有人可以给我任何关于如何确定错误的提示或建议。谢谢。
P.S。我也尝试过上传调试符号,但我认为应用中心页面有错误或者我可能做错了什么,问题是在尝试上传大约 20 分钟后页面被清理并且没有上传任何东西,这个过程我会尝试 7 次,但我从未成功上传 .appxsym
您看到的问题是由 .NET Native 工具链剥离代码以使程序集更小更快引起的。不幸的是,.NET Native 不够智能,无法理解何时需要反映类型,并且有时可能会删除您实际上需要的元数据。
调试这有点复杂,因为您需要尝试确切需要和缺少元数据的类型,并在 Default.rd.xml
文件中将此类型标记为必需,您可以在 Properties
UWP 项目中的文件夹。网上有个很有用的.NET Native MissingMetadataException troubleshooter。它旨在为您自动生成正确的 rd.xml 语法。您唯一需要做的就是填写 type/namespace 名称并指定类型的反映方式。
要找到问题的确切根源,请将构建配置切换到 Visual Studio 中的 Release
,然后将应用程序切换到 运行 并观察它在哪个点崩溃。有时它也有助于注释和取消注释代码以找出它发生的确切位置。在你的情况下,我怀疑这是由于 JSON 序列化和反序列化,这经常发生,因为类型仅用于此唯一目的,属性 "appear" 好像没有在任何地方引用。
感谢 Martin Zikmund 帮助我理解问题。
为了发现错误的根源,必须在启用 .NET Native 的情况下在 DEBUG 配置中进行编译(项目属性 > 生成 > 启用“.NET Native 工具链”复选框)。通过这种方式,我能够确定哪个是 MissingMetadataException,从而能够正确地形成 rd.xml 文件。
在我的例子中,它被更正为:
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterString" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterBoolean" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterObject" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterByteArray" Dynamic="Required All" />
<Type Name="System.Text.Json.Serialization.Converters.JsonConverterDateTime" Dynamic="Required All" />
</Application>
</Directives>
还要感谢 Jarvan y Matthew Whilden 抽出时间帮我解决问题。