我正在使用模板 10 NuGet 版本 1.1.4,并且在我的 Windows 10 移动设备上执行以下操作时看到以下异常:
- 运行应用程序
- 按 Windows 主页按钮(带我回到开始屏幕)
- 再次运行应用程序
发生的情况是应用程序无法启动,但以下情况除外:
Value does not fall within the expected range.
调用堆栈:
at Windows.UI.Xaml.Controls.ContentControl.put_Content(Object value)
at Template10.Common.BootStrapper.NavigationServiceFactory(BackButton backButton, ExistingContent existingContent, Frame frame)
at Template10.Common.BootStrapper.NavigationServiceFactory(BackButton backButton, ExistingContent existingContent)
at MyApp.App.OnInitializeAsync(IActivatedEventArgs args)
at Template10.Common.BootStrapper.<InitializeFrameAsync>d__77.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Template10.Common.BootStrapper.<InternalLaunchAsync>d__53.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()
如果我在 Visual Studio 中处于调试模式并使用生活方式事件暂停/恢复,则不会发生这种情况。
我不确定如何进一步调查?有任何想法吗?
谢谢。
编辑:我的OnInitializeAsync
功能看起来像:
public override Task OnInitializeAsync(IActivatedEventArgs args)
{
if ((Window.Current.Content as ModalDialog) == null)
{ // setup hamburger shell
var nav = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include);
nav.Frame.ContentTransitions.Clear();//disable animations
Window.Current.Content = new ModalDialog
{ DisableBackButtonWhenModal = true, Content = new Views.LoginPage(), ModalContent = new Views.Busy(), };
}
return Task.CompletedTask;
}
我唯一改变的Content = new Views.LoginPage()
是Content = new Views.Shell(nav)