首页 / C# / c# – UWP后台任务错误
c# – UWP后台任务错误
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – UWP后台任务错误,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2015字,纯文字阅读大概需要3分钟。
内容图文
![c# – UWP后台任务错误](/upload/InfoBanner/zyjiaocheng/767/f6615a51525244d5b9c2cc2eb361c9b7.jpg)
我想创建一个后台任务,它在应用程序启动时启动.为此我使用Application Trigger.
MainPage.xaml.cs中
var trigger = new ApplicationTrigger();
BackgroundManagement.RegisterBackgroundTask("InternetBackgroundTask.InternetBackground", "Internet", trigger, null);
await trigger.RequestAsync();
BackgroundManagement.cs
public static BackgroundTaskRegistration RegisterBackgroundTask(string taskEntryPoint,string taskName,IBackgroundTrigger trigger,IBackgroundCondition condition)
{
//
// Check for existing registrations of this background task.
//
foreach (var cur in BackgroundTaskRegistration.AllTasks)
{
if (cur.Value.Name == taskName)
{
//
// The task is already registered.
//
return (BackgroundTaskRegistration)(cur.Value);
}
}
//
// Register the background task.
//
var builder = new BackgroundTaskBuilder();
builder.Name = taskName;
builder.TaskEntryPoint = taskEntryPoint;
builder.SetTrigger(trigger);
if (condition != null)
{
builder.AddCondition(condition);
}
BackgroundTaskRegistration task = builder.Register();
return task;
}
Mytask在另一个项目上
namespace InternetBackgroundTask
{
public sealed class InternetBackground : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
System.Diagnostics.Debug.WriteLine("Run Background Task");
}
}
所以当我启动我的应用程序时,我有这个错误:
Exception thrown at 0x776BE26B (KernelBase.dll) in backgroundTaskHost.exe: 0x04242420 (parameters: 0x31415927, 0x5DE30000, 0x003CED68).
Exception thrown at 0x776BE26B in backgroundTaskHost.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x003CDF18.
Exception thrown at 0x776BE26B in backgroundTaskHost.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Exception thrown at 0x776BE26B in backgroundTaskHost.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x003CDF18.
我在项目中引用了我的后台任务,并在清单中添加了后台任务
解决方法:
你的剪辑中有两件事并不明显:
您是否已在Package.appxmanifest中的“声明”下声明了后台任务?
第二个:
什么项目类型是“InternetBackground.cs”?它应该是Windows运行时组件
内容总结
以上是互联网集市为您收集整理的c# – UWP后台任务错误全部内容,希望文章能够帮你解决c# – UWP后台任务错误所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。