Question

I'm getting this error message on my PC when I try to build my Windows Phone app:

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

I'm using Dropbox. On my laptop, It works perfectly fine and I can debug etc...On my PC however, I can't.

I tried many things such as:

  • Delete obj/Debug Folder
  • Check for files which are missing on the Solution Explorer

So far, nothing has helped.

Any idea how I can fix this?

Was it helpful?

Solution

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!

OTHER TIPS

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.

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.

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

Try the following:

  • Have Visual Studio closed
  • Download all your files to your computer
  • Delete Bin and obj folders completely.
  • Open the .sln
  • Rebuild

If if fails expand the References in te Solution explorer and make sure all your dll's are found. If a dll have a yellow exclamation point that means its not found. I'm thinking that one of your references are set to an absolute path on your laptop and that's missing on your PC.

If someone comes across this post and still has the issue I had where XAP packaging failed and that VS2012 can not find the file then check for spaces in the file name.

I had the issue where my tiles were "tilename 99.png" and it keep giving me the XAP packaging failed message. So I finally changed the file name to "tilename_99.png" and it worked.

Hope this helps someone in the same predicament.

In my case, I'd accidentally moved Background.png to a resource folder. Moved it back and it worked!

In my case, this error didn't go away even after trying all the above methods. Actually I had renamed the ApplicationIcon.png to "xyz.png". And reverting this, fixed the issue.

One more possibility is that you have a wrong path to an image in the project/options/Application dialog (icon, bg image, etc).

I had this error message, after some frustration I look in the obj folder, is was no part of the solution(but visual studio need it) but I had some conflicts files with dropbox. I deleted the obj folder rebuild, visual studio recreates the folder and the content of it and problem solved.

Ahh finally found my problem.

I'm using Visual Studio 2012, which doesn't always point out the "missing" file and makes it a little harder to fix.

MY SHORT SOLUTION

Relink the "linked" configuration file in the main project. It is a linked file because the original file remains in a referenced assembly, not in the current assembly. The file wasn't marked YELLOW so it wasn't obvious that it would be the problem, but when I double clicked on it, it failed to open, so I knew this was the problem file.

The silverlight application itself had a "linked" file called "ServiceReferences.ClientConfig" which contains information needed by a referenced project to make a web service call.

So the main project didn't have the web service reference itself, but it referenced a project which did, which is why it linked the "ServiceReferences.ClientConfig" file.

MY LONG SOLUTION

Keep rebuilding the main project file, and commenting out, and excluding project by project, file by file, until you CAN build the main project again. At that point it should be clear(er) which part of the solution is causing the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top