无法在Windows Phone Silverlight 8.1上添加后台代理作为参考

时间:2015-05-19 08:07:05

标签: windows-phone-8 visual-studio-2013 windows-phone-8.1 background-agents

我的应用程序使用Windows phone silverlight 8.1和visual studio express 2013.

我需要为我的应用安排任务,所以我在此处添加了一个Schedule Task项目:https://msdn.microsoft.com/en-us/library/windows/apps/hh202941%28v=vs.105%29.aspx

我设法添加了ScheduledTaskAgent但是当我尝试将其添加为我的项目的参考时(右键单击>添加参考),我收到了这样的消息:

"无法将所选参考添加为后台代理不支持"

我在一个新的简单项目上尝试了同样的方法,但它运行正常。

所以我试图删除我的其他引用并添加对我的计划任务的引用,但它仍然无效。

如何修复它并最终添加我的计划任务?是否有另一种方法可以将计划任务添加为参考?

我的后台经纪人:

using System.Diagnostics;
using System.Windows;
using Microsoft.Phone.Scheduler;

namespace ScheduledTaskAgent3
{
public class ScheduledAgent : ScheduledTaskAgent
{

    static ScheduledAgent()
    {
        Deployment.Current.Dispatcher.BeginInvoke(delegate
        {
            Application.Current.UnhandledException += UnhandledException;
        });
    }

    private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        if (Debugger.IsAttached)
        {

            Debugger.Break();
        }
    }


    protected override void OnInvoke(ScheduledTask task)
    {

        NotifyComplete();
    }
}
}

0 个答案:

没有答案