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

11

41

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?

Adai answered 29/1, 2012 at 16:51 Comment(3)
This may seem silly, but have you tried exiting and restarting Visual Studio? I've seen errors like this trying to compile Silverlight apps, and restarting VS almost always fixes it.Freeboard
Hey there. Yep, I've tried that. Still doesn't work. Any other ideas?Adai
Check if there are any References in the solution that are broken. After setting copy local to false you might be missing out on a referenced assembly.Band
P
75

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!

Pga answered 20/9, 2012 at 11:40 Comment(3)
awesome - I just had a single README.txt file that was missing, that resulted in this error.Laburnum
I had a .jpg file and the graphic artist send me new version as .png. Chaos ensued.Luwian
Same here. And for some reason, VS didn't a warning on that file until I clicked it...Vesica
F
22

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.

Fleck answered 2/5, 2012 at 20:58 Comment(0)
S
6

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.

Sloth answered 16/5, 2013 at 17:10 Comment(1)
+1 I opened my WPAppManifest.xml file in a text editor and changed the path to ApplicationIcon.png and Background.png manually, but re-selecting the images is just as easy.Superfine
T
5

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
Tadtada answered 30/1, 2012 at 9:11 Comment(2)
on VS 2010 Express: Right-click project / properties / Application Tab / startup object.Splay
sometimes it can be becasuse the application icon and/or background image have been relocated. Anyway it is good to restart VS after you fix this becase the error does not alwas go away. Check it outTitanesque
T
2

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.

Taxaceous answered 30/1, 2012 at 6:14 Comment(0)
L
2

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.

Leto answered 15/1, 2014 at 0:43 Comment(0)
R
1

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

Respirator answered 18/2, 2013 at 17:27 Comment(0)
S
0

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.

Sarthe answered 27/10, 2012 at 19:26 Comment(0)
K
0

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

Katiekatina answered 29/11, 2012 at 17:45 Comment(0)
T
0

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.

Turcotte answered 20/12, 2012 at 16:13 Comment(0)
B
0

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.

Boise answered 12/4, 2013 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.