Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:29:54+00:00 2026-06-17T07:29:54+00:00

I’m working on a WP8 app that uses a ScheduledTaskAgent to update a Live

  • 0

I’m working on a WP8 app that uses a ScheduledTaskAgent to update a Live Tile. It’s a pretty simple app, really. Problem is that while I’ve directly copied the code from the WP7 project to the WP8 project, it won’t launch the ScheduledTask. Not only that, but I get an error if I’m debugging and I try to launch the scheduled task for testing.

‘System.InvalidOperationException’ occurred in System.Windows.ni.dll

Not only that, but it doesn’t give me any stack to look through, and says that the source is not available, that I can look at the disassembly in the disassembly window, which means nothing to me. So, not a very helpful error, IMO.

I tried putting a break point in the constructor of the scheduled task, and it never makes it there. If I comment out the launch for test, no error. But of course, putting the app in my phone, it never launched, leaving it overnight.

Here’s my code:

var taskName = "TileUpdater";
            var oldTask = ScheduledActionService.Find(taskName) as PeriodicTask;
            if (oldTask != null)
            {
                ScheduledActionService.Remove(taskName);
            }
            if (useLiveTile)
            {
                //GenerateTileInfo();
                PeriodicTask task = new PeriodicTask(taskName);
                task.Description = AppResources.BackgroundTaskDescription;
                oldTask = ScheduledActionService.Find(taskName) as PeriodicTask;
                if (oldTask == null)
                {
                    ScheduledActionService.Add(task);
                }
#if DEBUG
                ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(10));
#endif
            }

The code works fine in the WP7 version. :/

This is in my WMAppManifest.xml file:

    <ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Specifier="ScheduledTaskAgent"
                                Name="xxxScheduledTask"
                                Source="xxxScheduledTask"
                                Type="xxxScheduledTask.SecheduledAgent" />
    </ExtendedTask>

In my scheduled task, the only thing I’m doing is calling a procedure that generates the tile info, updating the tile, and for the moment, I’m re-running the launch for test, so I can watch to see if it updates again, though I’ve had this commented out – I uncommented it to paste here, but that was commented out. Here is my OnInvoke method:

    GenerateTileInfo();

    #if DEBUG
        ScheduledActionService.LaunchForTest(task.ToString(), TimeSpan.FromSeconds(60));
    #endif

    NotifyComplete();

The GenerateInfo method doesn’t do anything that would cause a problem, but of course, it’s never getting there anyway. I did test my generating of the tile info, and implementing it, by placing that code in the MainPage.xaml.cs and calling it for now, to see if it worked, and the code I’m calling works fine. So if I open the app, the tile gets updated. Now I need to get the Background Task to work.

Any help that anyone can offer is greatly appreciated. One other clue is that last night I was getting an error that involved not being able to locate a pdb file – I think it was Microsoft.Phone.pdb, but whatever it was, it also referred to the System.Windows.ni.dll file, but now I’m not getting that pdb issue, just this InvalidOperationException. Last night the Debugging Symbols (I don’t know what that means) were not loading. Today they are. I don’t know what I did to fix it. Could have been a restart, for all I know.

Also, I tried creating a new project and copying my code to a new project, thinking I may have a corrupted project file, but the error I’m getting now is the same as I was getting earlier today that prompted me to create the new project.

Again, any help is appreciated. Thanks.

(Edit – New comments added below this point 12/29 at 11:34 am EST)
=================================================================================

I tried another expriment. I created a new project, and copy/pasted code from http://www.jeffblankenburg.com/2011/11/25/31-days-of-mango-day-25-background-agents/ to see if I could debug the app. I did have to make a few minor changes to the code that Jeff Blankenburg wrote, because he states that when you add the scheduled task project, it will automatically add to the WMAppManifest.xml file the following code, which it didn’t. I did that manually.

I also changed the StandardTileData type to FlipTileData (since that is what was default in the WP8 project) in the code that is pasted to the ScheduledAgent.cs.

Other than that, the only thing I did that Jeff doesn’t mention in his article is to add the necessary using directives.

Given the results of this experiment, I think I might be looking at somehow my Visual Studio install being corrupted. Would you concur? I’m thinking that doing an uninstall/reinstall of VS2012 and the phone sdk are what’s in order here, but since it takes so long, I wanted to get another opinion. Thanks.

Update (1/4/2012)
===============================================================

Uninstalled VS, went through the registry, then reinstalled VS2012, and phone SDK. Here’s what I get now – at least now it will show me the stack trace:

[Native to Managed Transition]
System.Windows.ni.dll!MS.Internal.JoltHelper.OnUnhandledException(object sender, System.UnhandledExceptionEventArgs args)
[Managed to Native Transition]
mscorlib.ni.dll!System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName fileName, string codeBase, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly locationHint, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks)
mscorlib.ni.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks)
mscorlib.ni.dll!System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool forIntrospection)
mscorlib.ni.dll!System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, bool forIntrospection)
mscorlib.ni.dll!System.Reflection.Assembly.Load(string assemblyString)
Microsoft.Phone.ni.dll!Microsoft.Phone.BackgroundAgentActivator.LoadEntryPointAssembly(string assemblyName)
Microsoft.Phone.ni.dll!Microsoft.Phone.BackgroundAgentActivator.LoadAgent(string assemblyName, string typeName)
Microsoft.Phone.ni.dll!Microsoft.Phone.BackgroundAgentActivator.Microsoft.Phone.IBackgroundAgentActivator.CreateBackgroundAgent(string assembly, string typeinfo)
Microsoft.Phone.ni.dll!Microsoft.Phone.BackgroundAgentDispatcher.AgentRequest.Invoke()
Microsoft.Phone.ni.dll!Microsoft.Phone.BackgroundAgentDispatcher.InvocationThread()
mscorlib.ni.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)
mscorlib.ni.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
mscorlib.ni.dll!System.Threading.ThreadHelper.ThreadStart()
[Native to Managed Transition]

Also considered that I was using the low memory emulator and had forgotten that background agents are not allowed in low mem devices, but which emulator (or device) I use makes no difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:29:56+00:00Added an answer on June 17, 2026 at 7:29 am

    After all this time of fighting with it, I’ve got the problem resolved. In copying the code from one project to another, I forgot to add a reference to the ScheduledTask project in the main project.

    I also learned a couple other things in the process of working on sample code to try to get it to work outside my project. First, when you add a ScheduledTask project it doesn’t seem to add the necessary metadata to the WMAppManifest.xml file, so you need to add that manually. The other thing is that when dealing with background agents, the error messages can be pretty cryptic, and may not say a thing about what the problem really is.

    From now on, when I see an error like I’ve seen here (I’ve seen several pretty cryptic errors, all seeming the same, but not quite) when working on Scheduled Tasks, that will be a prompt to be sure I’ve got a reference to the second project, and be sure the necessary info is in WMAppManifext.xml (including spelling – if you misspell it, it won’t be underlined).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.