BACKGROUNDTASKHOST.EXE“已退出,代码为1(为0x1)

编程入门 行业动态 更新时间:2024-10-08 18:41:48
本文介绍了BACKGROUNDTASKHOST.EXE“已退出,代码为1(为0x1) - 发行地理围栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写的Windows Phone使用栅栏API 8.1的应用。我的问题是,我不能触发后台任务的位置变化,因为应用程序的代码1退出。

I am writing Windows Phone 8.1 Application using GeoFence API. My problem is that I can't trigger change of location in Background Task, because app exits with code 1.

我看了一下这个错误多线程,但没有解决办法解决了我的问题。

I have read multiple threads about this error, but no solution solved my problem.

  • 我已签,如果我的BackgroundTask是一个运行时组件,它是。
  • 我已签的名字我的班,这是正确的。
  • 我,如果我用我的BackgroundTask功能的任何等待功能检查,我没有发现任何。
  • 我已签,如果我注册后台任务的应用程序清单,是的,我做(与入口点OFC)
  • I have checked if my BackgroundTask is a Runtime Component, and it is.
  • I have checked name of my class and it is correct.
  • I have checked if I use any await function in my BackgroundTask function and I didn't find any.
  • I have checked if I registered Background Task in app manifest and yes, I did (with entry point ofc)

在事实上的错误甚至出现从BackgroundTask运行运行功能了。

In fact error appears even before running Run function from BackgroundTask.

namespace BackgroundTask { public sealed class geoFenceBackgroundTask : IBackgroundTask { public void Run(IBackgroundTaskInstance taskInstance) { ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode("MY APP")); toastTextElements[1].AppendChild(toastXml.CreateTextNode("Test")); //IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); //XmlElement audio = toastXml.CreateElement("audio"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } }

和我的寄存器功能:

async private void RegisterBackgroundTask() { // Get permission for a background task from the user. If the user has already answered once, // this does nothing and the user must manually update their preference via PC Settings. BackgroundAccessStatus backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); // Regardless of the answer, register the background task. If the user later adds this application // to the lock screen, the background task will be ready to run. // Create a new background task builder BackgroundTaskBuilder geofenceTaskBuilder = new BackgroundTaskBuilder(); geofenceTaskBuilder.Name = "geoFenceBackgroundTask"; geofenceTaskBuilder.TaskEntryPoint = "BackgroundTask.geoFenceBackgroundTask"; // Create a new location trigger var trigger = new LocationTrigger(LocationTriggerType.Geofence); // Associate the locationi trigger with the background task builder geofenceTaskBuilder.SetTrigger(trigger); // If it is important that there is user presence and/or // internet connection when OnCompleted is called // the following could be called before calling Register() // SystemCondition condition = new SystemCondition(SystemConditionType.UserPresent | SystemConditionType.InternetAvailable); // geofenceTaskBuilder.AddCondition(condition); // Register the background task var geofenceTask = geofenceTaskBuilder.Register(); geofenceTask.Completed += (sender, args) => { // MY CODE HERE }; geofenceTask = geofenceTaskBuilder.Register(); }

我没有其他想法。任何帮助吗?

I have no other ideas. Any help?

推荐答案

只是偶然发现了一个类似的问题(Visual Studio中stoipped调试时,我开始了后台任务的lifecyle-事件 - 下拉,指出BACKGROUNDTASKHOST.EXE已与代码1(为0x1)退出,在控制台输出-窗口。

just stumbled upon a similar issue (Visual Studio stoipped Debugging when i started the Background Task over the "lifecyle-events-Dropdown", stating "BACKGROUNDTASKHOST.EXE' has exited with code 1 (0x1)" in the COnsole-Output-Window.

添加缺少参考我的任务在WP8项目 - 装配(winmd)项目解决了这个问题。

Adding the missing reference to my Tasks-Assembly (winmd) Project in the WP8 Project solved it.

更多推荐

BACKGROUNDTASKHOST.EXE“已退出,代码为1(为0x1)

本文发布于:2023-11-12 20:42:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   BACKGROUNDTASKHOST   EXE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!