Windows Phone Silverlight App Crashes on Startup - A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Phone.dll

Posted by Blake on 12/29/2011

The above exception can mean a lot of things, but one to look for in particular when your WP7 Silverlight app crashes during startup is whether it knows what page to open by default. If you delete the main page that is created with your project it maybe trying to still start that page. The editor itself doesn’t really stop anywhere meaningful to give you a clear indication as to what the problem is (it will stop in the Application_UnhandledException sub in App.xaml.vb).

I haven’t found a way to edit the startup page from the Visual Studio dialog editors, but you can edit the WMAppManifest.xml file easily enough. It’s located under “My Project” in the Solution Explorer. If “My Project” cannot be expanded, hit the “Show All Files” button on the Solution Explorer toolstrip.

There will be a section in the XML file called Tasks. Edit the DefaultTask entry and change the name of the .xaml file to the page you want to startup.