[英]UWP App RequestRestartAsync Throws Exception in System.Private.Corelib
My computer is on Windows 10 build 16299, which is the minimum required version for the UWP restart functionality in CoreApplication.RequestRestartAsync(...)
. 我的计算机在Windows 10内部版本16299上,这是CoreApplication.RequestRestartAsync(...)
的UWP重新启动功能的最低要求版本。 However, after I make the call to restart, with arguments of string.Empty
, the App does close and a few seconds later an Exception is thrown from System.Private.CoreLib.dll
: 但是,在我使用string.Empty
参数进行重新启动的调用之后,该应用程序确实关闭了,几秒钟后,从System.Private.CoreLib.dll
抛出了异常:
Exception occurred: System.Exception: Exception from HRESULT: 0x80040900
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
I am able to get this information from a Try/Catch block and am running the app from Visual Studio 2017 in debug mode. 我可以从Try / Catch块中获取此信息,并以调试模式从Visual Studio 2017运行该应用程序。 Before I attempted to catch it, a dialog would appear indicating to debug in another instance of Visual Studio. 在尝试捕获它之前,将出现一个对话框,指示在Visual Studio的另一个实例中进行调试。 When the other instance loaded, this was not allowed because it said a debugger was already attached. 当加载另一个实例时,这是不允许的,因为它说调试器已经连接。
Additionally, I tried to catch it by enabling "Common Language Runtime Exceptions", but it did not catch this Exception. 此外,我尝试通过启用“公共语言运行时异常”来捕获它,但没有捕获此异常。
Why is this happening? 为什么会这样呢? When I use run this on another Windows 10 machine, the restart works fine. 当我使用在另一台Windows 10计算机上运行此命令时,重启工作正常。 Can I debug or get more information about the Exception in System.Private.CoreLib
? 我可以在System.Private.CoreLib
调试或获取有关Exception的更多信息吗?
This error will not happen to affect your app's real experience when you install your app and run it without connecting the Visual studio to debug. 当您安装应用程序并在未连接Visual Studio进行调试的情况下运行应用程序时,此错误不会影响您的应用程序的真实体验。 Visual Studio prevents Windows from suspending an app that is attached to the debugger. Visual Studio防止Windows挂起附加到调试器的应用程序。 This is to allow the user to view the Visual Studio debug UI while the app is running. 这是为了允许用户在应用程序运行时查看Visual Studio调试UI。 When you debug this code with Visual Studio, you can see the App status is still Running in your device Task Manager => Details tab after you called this method, so the app can not restart, since prior to Windows 10, version 1803, only one instance of a UWP app could be running at a time. 使用Visual Studio调试此代码时,调用此方法后,您可以在设备的任务管理器 => 详细信息选项卡中看到应用程序状态仍在运行 ,因此该应用程序无法重新启动,因为仅在Windows 10版本1803之前一个UWP应用实例可以一次运行。 More details about multi-instance UWP, please see Create a multi-instance Universal Windows App . 有关多实例UWP的更多详细信息,请参阅创建多实例通用Windows应用程序 。
But in my test on the device OS version 1803 OS build 17134 and Visual studio version 15.7, it will disconnect the Visual Studio debugger automatically after you call CoreApplication.RequestRestartAsync(string.Empty)
code. 但是,在对设备操作系统版本1803,操作系统内部版本17134和Visual Studio版本15.7进行的测试中,调用CoreApplication.RequestRestartAsync(string.Empty)
代码后,它将自动断开Visual Studio调试器的连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.