Xap packaging failed. Object reference not set to an instance of an object

The problem lies in your startup object in your Application. I have met this error to many times.

It usually happens when I change the name of my class/namespace Application class. Or it might even be conflicting with your dropbox locations.

To Fix this.

  1. Right click your main project or Alt+Enter
  2. Go to the silverlight tab and set your startup object

You should check, in every folder of your project, for missing files or wrong references.

You can get this problem just with a single missing image, if its Build Action property is set to Content or similar...

enter image description here

Check your files and then Rebuild your project!


I am adding this reply because although the problem with app icons is covered in brief in some of the answers above, I wanted to give exact steps since it just happened to me. I got this error and then found this web page:

Xap Packaging Error

It turned out that my App icon file name was wrong due to a rename. I double-clicked on WMAppManifest.xml, found in the Properties folder, to open the editor for that file. I simply used the button to update the App Icon, re-found the file and selected it, and the error went away after rebuilding the project.


This can happen if a file is removed from the disk itself, but not from the Solution through Visual Studio. Delete the file through Visual Studio (it should be marked with a little yellow hazard icon) and Rebuild.

Credit to Andreas Hammar via http://blog.jayway.com/2011/06/03/wp7-build-error-xap-packaging-failed/ - his solution worked for me.