我开发了带有传感器的监控系统,该应用程序必须运行365天24小时。

现在,我正在测试该应用程序是否可以长期运行。为了防止暂停,我写了这个。

<Capabilities>
<Capability Name="internetClient" />
<!--<rescap:Capability Name="runFullTrust" />-->
<rescap:Capability Name="extendedBackgroundTaskTime" />
<rescap:Capability Name="extendedExecutionUnconstrained" />
<DeviceCapability Name="serialcommunication">
  <Device Id="any">
    <Function Type="name:serialPort" />
  </Device>
</DeviceCapability>


并且我也添加了此代码。

        Window.Current.CoreWindow.Activated -= CoreWindow_OnActivated;
        Window.Current.CoreWindow.Activated += CoreWindow_OnActivated;

private void CoreWindow_OnActivated(CoreWindow sender, WindowActivatedEventArgs args)
    {
        // This seems to be the last chance we get to enable extended execution when going to the background.
        // Trying this on OnVisibilityChanged, OnEnteredBackground, or OnSuspending is too late.
        if ((null != args) && (CoreWindowActivationState.Deactivated == args.WindowActivationState))
        {
            ExtendedExecutionManager.Instance.BeginExtendedExecutionIfNeeded();
        }
    }


在第一次测试中,我的应用程序可以运行3天21个小时。但是突然,它已经关闭,没有任何错误,没有任何事件查看器日志。

这是UWP应用程序的限制吗?

该应用程序将作为“侧载”软件包安装。

更新1:

当我进行侧向载荷应用时,我对此进行了检查。但Eventviewer没有异常记录。有什么方法可以知道UWP应用程序崩溃日志吗?

uwp - 3天21个小时后UWP应用程序关闭-LMLPHP

更新2

我试图测试小型UWP应用程序,并故意抛出异常。
使用,在侧面加载包中没有PDB文件的情况下,EventViewer捕获“ Applicaton错误”。但是我的应用程序崩溃了,在eventViewer上没有任何消息...

我想说为什么...但是没人能回复.....
请给我更多评论。

要使用WPF进行重建,这是不可能的,这将需要6个月的时间!

uwp - 3天21个小时后UWP应用程序关闭-LMLPHP

(第一个错误是sideload中的PDB文件。最后一个错误是没有PDB)

最佳答案

我终于选择了以下想法。


下载并运行它。(免费应用程序“ Restart on Crash”)
使批处理文件在崩溃时重新启动。(How to
使用“崩溃时重启”应用程序,像这样进行安装。


uwp - 3天21个小时后UWP应用程序关闭-LMLPHP

像这样的批处理文件。

@echo off
start shell:AppsFolder\2313d654-0c37-461f-ae1e-31336dde7fb3_sasbmbdd83txa!App


关闭UWP应用程序后,免费软件立即重新启动!
对我来说,足够了。

谢谢Stackoverflow的用户!

关于uwp - 3天21个小时后UWP应用程序关闭,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47785850/

10-11 02:24
查看更多