Is your WP7 app/emulator unexpectedly dying on you without warning?
Apr
12
Written by:
Monday, April 12, 2010 10:54 PM
When you run your WP7 app in the emulator, does it die unceremoneously, without warning, without ANY indication of WTF is going on? I think I have two clues for you! Please read on!
For the last two nights, I've been fighting with my WP7 app dying on me without ANY indications of WTF was going on!!!! ggggrrrrrr After 2:00AM last night, I THOUGHT I had it licked, but then it came BACK tonight. GGGGRRRRR
SVN saved me last night, maybe it can do it again tonight? hhhmmm wait a sec, something's not right here, everything started to go south (like the Leafs in the playoffs? LOL) but something finger flicked my brain (I HATE it when that happens) to look at the Assembly Startup object.....hhhmmmmm clue #1 my dear Watson!
This all started when I wanted to change/modify my namespaces. Seems like a simple enough thing to do right? We all do refactoring right? Right? RIGHT? And that's clue #2 Watson!
I started off with updating the project's Assembly info. Below is the before and after picture. Notice the Startup object is the WP7App.App. And that's the "finger flick" I should have been paying attention to earlier! I guess I just assumed the renaming would ACTUALLY RENAME IT EVERYWHERE....but I'm getting ahead of myself.
Once I changed the Assembly info, next it's time to update the XAML. Easy enough to do with Search'n'Replace.
Cool, things are going smoothly so far right? Yup, I thought so too for the PAST TWO NIGHTS AS WELL! But I digress, let's continue.
Next is code/C#. Notice how cause the XAML changed, InitializeComponent() is mucked up? Let's go ahead and do another Search'n'Replace, and BINGO, everything's happy again.
See, even the CSC.exe says everything is good. Hey, if it compiles, it should be good right?

WEEEEEEEEEEEEEEEEEELL, the problem is, this is where things started to fall off the rails. When I hit F5 to run, everything started up JUST fine, the SplashScreenImage.jpg even comes up correctly, but then, JUST as soon as I'm about to think easy-as-pie.......the WP7 app dies! DOH! HUH? What happened. Putting breakpoints inside ANYWHERE won't work! There's NO uncaught exceptions, there's no KNOWN exceptions being thrown. It's as if nothing's being run, BUT the SplashScreenImage IS coming up, so VS knows enough to run my app. What's going on? I'm going crazy!
Well, back to my clues above Watson! Let's revisit the Assembly Startup object now, yup, after refactoring.......hhhhmmmmm Where's the Startup object?????!!!!! THAT'S IT! Mind you, the first time I ran this, I was left with the default "WP7App.App" which I had NO way to change/update/modify.

Now, in my case, up above, it was a SIMPLE matter of selecting the new OITD.Kiost.WP7App.App and everything was GREAT again.

However, the first time I did this, I had a problem, there wasn't any such option, nope, it continued to have the OLD reference in there no matter what I changed, nor how ever many times I power cycled VS2010!
The trick was to manually modify the project's SilverlightAppEntry node. Yup, back to hand coding XML files, but only for a quick moment.

Above, you'll see what I saw before I started with the refactoring efforts above. Once I made the manual change, I was back to the OITD.Kiosk.WP7App.App again, and everything ran perfectly!
Now that you know how to diagnose and hopefully fix your latest WP7 Emulator "issue" with refactoring, it's time to grab a coffee and get coding!
9 comment(s) so far...
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Try renaming the namespace in the code editor (i.e. in a class file). Renaming a namespace performs the Rename Namespace Refactoring and will rename all instances of the namespace. If the namespace you are renaming is the default namespace it will rename it in the Project Settings. See http://msdn.microsoft.com/en-us/library/6kxxabwd.aspx
You're likely not going to get in a stituation where the Startup Object doesn't exist.
By Peter Ritchie on
Tuesday, April 13, 2010 12:49 PM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
AAAHHHHHHH I see now! So if you refactor namespaces using the F2, then it works? I'm trying it out now (albeit in VS2008, that's all I have @ w) and it seems to work nicely! Thank you Peter!
It even gives you a chicken switch to stop the process cause you can't CTRL+Z this change.
"The following projects place automatically generated code into the namespace you are renaming: WinForms If you proceed rename will update these projects. However this 'Default Namespace' update cannot be undone through Edit->Undo."
Cool, so this CAN be done, just through a more explicit means. Thanks Peter!
By phenry on
Tuesday, April 13, 2010 12:59 PM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Nice tip. It took me a couple days to figure this out.
By Wow on
Thursday, November 18, 2010 9:44 AM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Hi Wow! Thank you for leaving a comment. Sorry you got burned on this one too. Ironically I got burned on it two weeks ago AGAIN! DOH! But only for 20m or so before something finger-flicked my brain to go look at this blog entry. Hope you come back again soon. THanks for the comment and have a good day!
By phenry on
Thursday, November 18, 2010 10:09 AM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Thank you sooo much!!! I had exactly the same problem and you saved me tons of time!
Thanks again
By Tim on
Thursday, February 24, 2011 1:48 PM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Hey COOL! I'm glad I was able to help you out Tim! And thank you so much for your comments! Not having the best of weeks, so this certainly helps to lift my spirits! Thanks.
By Peter Henry on
Thursday, February 24, 2011 2:15 PM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Thanks man! It didn't work here even though I used refactor rename.
By žiga on
Tuesday, March 01, 2011 2:02 PM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Hi ziga, this didn't work above? YIKES! There's something else at play there then IMHO! Crap! I wish I could help you out more, but without the project/solution I'm a bit in the dark too. Another solution is to start from scratch, bring in the classes/forms one by one, compiling as you go, then when it's all done, compare the proj/sln files to see what's different. Mind you, by that time, you probably don't care about the solution and just want to get things working. I'm sorry the above didn't work out for you, but I DO hope you come back and comment again if you do find out what your problem is/was. Thanks for commenting, I hope you do get it working!
By Peter Henry on
Tuesday, March 01, 2011 4:49 PM
|
Re: Is your WP7 app/emulator unexpectedly dying on you without warning?
Andreas Hammar also found this problem/solution as well. Follow the link to his blog for additional information. blog.jayway.com/2011/10/12/fixing-wp7-app-not-starting-after-project-rename/comment-page-1/#comment-79139
By Peter Henry on
Monday, November 14, 2011 4:05 PM
|