【问题标题】:UWP App Crash Using Extended Execution使用扩展执行的 UWP 应用程序崩溃
【发布时间】:2018-07-20 18:56:24
【问题描述】:

我已经实现了 Magnus Montin Non-suspending UWP Desktop Apps 给出的例子

我们是 ISV,无法访问用户计算机,因此必须按照 Magnus 为提交到商店的应用程序提供的指示实施解决方案

将 ExtendedExecutionForegroundSession 替换为 ExtendedExecutionSession,将其 Reason 属性设置为 ExtendedExecutionReason.Unspecified

我们也使用 Template10。我在 App.xaml.cs 中的实现是

ExtendedExecutionSession _session;
private void SessionRevoked(object sender, ExtendedExecutionRevokedEventArgs args)
{
    if (_session != null)
    {
        _session.Dispose();
        _session = null;
    }
}
private async Task PreventFromSuspending()
// stolen from https://blogs.msdn.microsoft.com/mvpawardprogram/2018/01/30/non-suspending-uwp-desktop-apps/
{
    ExtendedExecutionSession newSession = new ExtendedExecutionSession();
    newSession.Reason = ExtendedExecutionReason.Unspecified;
    newSession.Revoked += SessionRevoked;

    ExtendedExecutionResult result = await newSession.RequestExtensionAsync();
    switch (result)
    {
        case ExtendedExecutionResult.Allowed:
            _session = newSession;
            break;
        default:
        case ExtendedExecutionResult.Denied:
            newSession.Dispose();
            break;
    }
}
public override async Task OnInitializeAsync(IActivatedEventArgs args)
{
    if (_session == null)
        await PreventFromSuspending();
}

这现在在商店中,并且与我们在 AppCenter 中最常见的崩溃有关。该项目称为 UWP。堆栈跟踪是

    myapp::app::_preventfromsuspending_d__4 movenext()
stowed_exception_system.exception 8007139F: stowed_exception_system.exception

System.Private.Interop
System::Runtime::InteropServices::McgMarshal ActivateInstance() McgMarshal.cs:1331
UWP.McgInterop.dll
Windows::ApplicationModel::ExtendedExecution::ExtendedExecutionSession. ctor() SafeTypes.g.cs:50719
UWP.exe
MyApp::App::_PreventFromSuspending_d__4 MoveNext() App.xaml.cs:80
SharedLibrary.dll
System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:61
System.Private.Threading
System::Runtime::CompilerServices::TaskAwaiter ThrowForNonSuccess() TaskAwaiter.cs:182
System.Private.Threading
System::Runtime::CompilerServices::TaskAwaiter HandleNonSuccessAndDebuggerNotification() TaskAwaiter.cs:151
System.Private.Threading
System::Runtime::CompilerServices::TaskAwaiter ValidateEnd() TaskAwaiter.cs:123
System.Private.Threading
System::Runtime::CompilerServices::ConfiguredTaskAwaitable::ConfiguredTaskAwaiter GetResult() TaskAwaiter.cs:108
UWP.exe
MyApp::App::_OnInitializeAsync_d__5 MoveNext() App.xaml.cs:16707566
SharedLibrary.dll
System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:61
System.Private.Threading
System::Runtime::CompilerServices::TaskAwaiter ThrowForNonSuccess() TaskAwaiter.cs:182
System.Private.Threading
System::Runtime::CompilerServices::TaskAwaiter HandleNonSuccessAndDebuggerNotification() TaskAwaiter.cs:151
System.Private.Threading
System::Runtime::CompilerServices::TaskAwaiter ValidateEnd() TaskAwaiter.cs:123
System.Private.Threading
System::Runtime::CompilerServices::ConfiguredTaskAwaitable::ConfiguredTaskAwaiter GetResult() TaskAwaiter.cs:108
Template10Library.dll
Template10::Common::BootStrapper::_StartupOrchestratorAsync_d__112 MoveNext() +0x00000000000002A0
SharedLibrary.dll
System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:61
System.Private.Threading
System::Runtime::CompilerServices::AsyncMethodBuilderCore::__c _ThrowAsync_b__9_0() AsyncMethodBuilder.cs:971
System.Private.Threading
System::Threading::SendOrPostCallback Invoke() +0x0000000000000028
System.Private.Threading
System::Threading::WinRTSynchronizationContext::Invoker InvokeCore() SynchronizationContext.cs:170
System.Private.Interop
System::Runtime::InteropServices::McgMarshal ThrowOnExternalCallFailed() McgMarshal.cs:1267
UWP.McgInterop.dll
__Interop::ComCallHelpers Call() SharedStubs.g.cs:11991
UWP.McgInterop.dll
__Interop::ForwardComStubs.Stub_16_System __Canon_() SharedStubs.g.cs:645
Microsoft.AppCenter.dll
Microsoft::AppCenter::Utils::ApplicationLifecycleHelper._ ctor_b__17_1$catch$0() +0x000000000000001D
System.ObjectModel.dll
System::Collections::Specialized::NotifyCollectionChangedEventHandler Invoke() +0x000000000000001B
UWP.McgInterop.dll
__Interop::Intrinsics.HasThisCall__45_System __Canon_() +0x0000000000000036
UWP.McgInterop.dll
__Interop::ReverseComStubs.Stub_9_System __Canon_() SharedStubs.g.cs:27913
System.Private.Interop
System::Runtime::InteropServices::McgMarshal ThrowOnExternalCallFailed() McgMarshal.cs:1267
UWP.McgInterop.dll
__Interop::ComCallHelpers Call() SharedStubs.g.cs:11991
UWP.McgInterop.dll
__Interop::ForwardComStubs.Stub_16_System __Canon_() SharedStubs.g.cs:645
UWP.exe
MyApp::App UnhandledError$catch$0() App.xaml.cs:34
System.ObjectModel.dll
System::ComponentModel::PropertyChangingEventHandler InvokeOpenStaticThunk() +0x0000000000000027
System.ObjectModel.dll
System::Collections::Specialized::NotifyCollectionChangedEventHandler Invoke() +0x000000000000001B
UWP.McgInterop.dll
__Interop::Intrinsics.HasThisCall__45_System __Canon_() +0x0000000000000036
UWP.McgInterop.dll
__Interop::ReverseComStubs.Stub_9_System __Canon_() SharedStubs.g.cs:27913

对于如何更好地实现扩展执行以防止此崩溃的任何帮助,我将不胜感激。

【问题讨论】:

    标签: uwp windows-store-apps


    【解决方案1】:

    为了实现扩展执行,我建议你按照文档Postpone app suspension with extended execution和参考官方的ExtendedExecution代码示例,然后检查你项目中的代码,找出问题所在。

    【讨论】:

    • 告诉我查看文档并检查我的代码不是答案。尽管对文档的引用可能是答案的有用部分,但它并不能回答问题。我上面的代码似乎在功能上等同于文档。我一直无法在我的开发机器上强制执行 ExtendedExecution 错误,但这个错误在 Microsoft App Center 中对我们来说是最常见的,而且堆栈跟踪对我来说意义不大。
    • 您上面的代码找不到任何问题发生在哪里,所以我只能提供基本文档供您自己解决项目问题。您能否在您的设备中重现崩溃或提供简单的重现示例?此外,您可以尝试使用 Hockey 应用程序收集崩溃信息以获取更多崩溃详细信息Crash Reporting for UWP
    • 我的理解@Breeze Liu - MSFT 是 HockeyApp 已集成到 Microsoft App Center 中。我们在我们的应用程序中实现了 App Center Analytics 和 App Center Crashs。上面的堆栈跟踪来自我们应用的 Microsoft App Center 崩溃报告。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多