"Object reference not set to an instance of an object" when you try to run a WP7 app?
Apr
12
Written by:
Monday, April 12, 2010 9:06 PM
Are you getting an "Object reference not set to an instance of an object" error message when you F5/start running your WP7 app? Read on, the solution is MUCH simpler than you think!
So! You wrote your first WP7 app? COOL! Then you goto sleep, next day you wake up, work, return home, have supper, open up VS, hit F5 and BOOM!!!!!!!!!! You're staring RIGHT into something that LOOKS like an uncaught exception, but it's not labeled as such, it's not a KNOWN exception, cause well, it's not showing an exception type, nor a stacktrace. Your app just dies on the table! DOH! WTF?
"Object reference not set to an instance of an object"
Turns out, the problem is rather simple (IMHO!). Check out my steps to repro above, you just opened up VS and hit F5 right? Chances are, you're solution is the currently selected node in the Solution Explorer tree, right?

If that's the case, then the solution is as simple as selecting another project and hitting F5 again. YUP! It's THAT simple.

I want to thank Rob Miles and Ginny Caughey for the heads up and the fix! For without their blogs/posts/tweets, I would have torn what little hair I have left, OUT!
Now that you can keep your hair too! LOL It's time to grab a coffee and get coding!
Resources
robmiles.com: Why do I get an “Object reference not set to an instance of an object” error when I run my program?
Twitter: Ginny Caughey