使用扩展执行的UWP App崩溃

时间:2018-02-09 23:07:33

标签: uwp windows-store-apps

我已经实施了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

我很感激有关如何更好地实施扩展执行以防止此崩溃的任何帮助。

1 个答案:

答案 0 :(得分:0)

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