0

I am trying to submit an app to the app hub, whick is using a backgound agent to update the app tile. the background agent requires to use the Microsoft.Phone.dll, but when I submit the app i get the following errors

2011: The background agent can’t use Microsoft.Phone.Shell.ShellTile::Create, which assembly TileAgent.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::Pause, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::Stop, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::Play, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::set_Position, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::set_AutoPlay, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::SetSource, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Media.VideoBrush, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

2011: The background agent can’t use System.Windows.Controls.MediaElement::.ctor, which assembly Microsoft.Phone.dll is trying to use. Update your file and then try again.

although I am not using any of those assemblies, or reference them anywhere in the agent's project. please help!

EDIT: I removed the create tile method, and now this error is gone. the rest though remain the same, although I am not using any of them There is absolutely no use of the System.Widnows.Contols in this project

EDIT: Here is the list of referenced i have in the agent's project

Microsoft.Phone
mscorelib
mscorelib.extensions
system
System.Core
System.Net
System.Windows
System.Xml
user970012
  • 106
  • 1
  • 9

3 Answers3

0

You can't use some APIs from a scheduled task.

See http://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspx for more information.

Sami Rajala
  • 191
  • 1
  • 11
  • yes i know, i dont use them! i did have a crate thethod for a tile, which i removed, but the rest, simply dont even exist in the background agent's project – user970012 Oct 09 '12 at 09:24
  • Are you still referencing some restricted libraries in your background agent project? – Sami Rajala Oct 09 '12 at 09:35
  • nope", thats why i'm so confused, i dont need them and i dont use them. i searched the whole project again and again, no reference, nothing – user970012 Oct 09 '12 at 09:46
  • it says that the assembly Microsoft.Phone.dll is trying to use them, but i dont know how and why it is trying to use them – user970012 Oct 09 '12 at 09:48
  • And you don't reference another project in your solution that might use them? – Sami Rajala Oct 09 '12 at 10:20
0

Your agent has some references to code wich uses listed API. For example:

You have some class wich creates new tile. Microsoft.Phone.Shell.ShellTile::Create. And your background agent lives in the same proj, or your bg agent uses code wich lives in proj where you create new tile.

Some illustration:

proj A

 //draws tile 
 public class TileBuilder() {}
 //creates new tile using TileBuilder() 
 public class NewTileManager(TileBuilder tBuilder) 
 {
 }

proj B

  public class ScheduledAgent : ScheduledTaskAgent
  {
      protected override void OnInvoke(ScheduledTask task)
      {
        //update data
        var tBuilder = new TileBuilder(); // oops, you use code from proj A. 
                                          // So, you have it
                                          // as a reference, And MS thinks that 
                                          // your bgAgent uses forbidden API

      }

}
Anton Sizikov
  • 9,105
  • 1
  • 28
  • 39
  • Thank you Anton. I solved the problem with the create method error, I cannot find a solution for the rest. I simply dont use System.Widnows.Contols anywhere, i just use 2 strings, one for the title and one the image link for the tile update, that's it – user970012 Oct 09 '12 at 09:28
  • Somewhere in your code you have a video controls. Play\pause logic. Am I right? – Anton Sizikov Oct 09 '12 at 09:57
  • not in my agent project, nowhere. i just create new tiledata and update a tile with 2 strings. the windows phone project, which is using the agent has video, i tried removing it, but it has no connection with these errors, still the same output – user970012 Oct 09 '12 at 10:21
  • i did this, i also totally deleted the output in bin to be sure and rebuilt it – user970012 Oct 09 '12 at 11:26
  • also i created an new agent from scratch, and added the tile update method in there, still the same errors – user970012 Oct 09 '12 at 11:27
  • the weird thing is, this app runs perfectly when installed on 2 wp7 devices and on the emulator, too, i am starting to believe this is amarketplace bug – user970012 Oct 09 '12 at 11:32
  • Do you have xaml files in this proj? – Anton Sizikov Oct 09 '12 at 11:32
  • Also, before submitting to the marketplace run this http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394032(v=vs.92).aspx – Anton Sizikov Oct 09 '12 at 11:34
  • i dont see anything with more info there, just a list same as above – user970012 Oct 09 '12 at 11:57
  • Ok, add to the question the list of projects referenced to your agent proj. – Anton Sizikov Oct 09 '12 at 13:05
0

I know this is old, but I have a hacky solution. You can't use those methods in a background agent. If you would really like to do so, use reflection. But make sure that you don't actually call any of that code from the background task, as this would not be allowed.

For example, for ShellTile.Create:

 using System.Reflection;

   ...

      Uri NavUri = //your tile's navigation URI
      ShellTileData data = //your tile's data

      object[] parameters = { NavUri, data};
      Type[] types = new[] { typeof(Uri), typeof(ShellTileData)};
      Type type = typeof(ShellTile);
      MethodInfo info = type.GetMethod("Create", types);
      info.Invoke(null, parameters);

That will trick the Dev Center into accepting your xap.

msbg
  • 4,852
  • 11
  • 44
  • 73