重新注册时UWP Backgroundtask崩溃

人气:416 发布:2022-09-22 标签: wpdevelop

问题描述

您好,

我发现,当我第二次尝试注册backgroundtask时,我的应用程序使用ApplicationTrigger触发后台任务崩溃。所以在注册后 - >取消注册 - >注册,它崩溃。

在Microsoft在Github上提供的BackgroundtaskSample应用程序中执行相同操作时也会发生这种情况:

https:// github。 com / Microsoft / Windows-universal-samples / blob / master / Samples / BackgroundTask / cpp /

但是,它只发生在与ApplicationTrigger关联的后台任务中,而不是其他任务。

为什么会出现这种情况?如何解决?

解决方案

Hello Durrsen,

您的操作系统版本和目标SDK是什么您的开发机器上的版本?如果您在另一台计算机上复制并运行代码,是否可以重现相同的问题?当你尝试捕获异常时,你能找到关于你的异常的任何信息吗?

当我使用官方演示时,如果我第二次注册,我只会得到以下异常:

BackgroundTask.exe中0x00007FFFF35CA388抛出异常:Microsoft C ++异常:Platform :: COMException ^在内存位置0x00000094A23FCAB0。 HRESULT:0x800700B7当该文件已存在时无法创建文件。 WinRT信息:当该文件已存在时无法创建文件。

但这不应该是你遇到的错误,对吗?您能否向我们提供更多信息?

致以最好的问候,

Barry

Hello,

i found out, that my application that uses an ApplicationTrigger to trigger a backgroundtask crashes when trying to register the backgroundtask a second time. So after Register -> Unregister -> Register, it crashes.

This also happens when doing the same in the BackgroundtaskSample application provided by Microsoft on Github:

https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/BackgroundTask/cpp/

However, it only happens for the Background Task associated with the ApplicationTrigger, not the other ones.

Why is this behaviour occuring? How to fix it?

解决方案

Hello Durrsen,

What's your OS version and target SDK version on your dev machine? Can you reproduce the same problem if you copy and run your code on another machine? When you try and catch the exception, can you find any info about your exception?

When I use the official demo, if I register the second time, I will only get the following exception:

Exception thrown at 0x00007FFFF35CA388 in BackgroundTask.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x00000094A23FCAB0. HRESULT:0x800700B7 Cannot create a file when that file already exists. WinRT information: Cannot create a file when that file already exists.

But it should not be the error you meet, right? Can you provide more info to us?

Best regards,

Barry

430