I was working on transforming a Windows Store app into an Universal app so that it worked not just for Windows Store but also for Windows Phone. When you do this two new projects are added to the solution. One of them is a special one, called shared project that you can use to keep files shared between platforms.
In my case, one of those shared files were the App.xaml and App.xaml.cs. So what I did was moving these files from the original Windows Store app to the shared folder and then delete the copies from each platform specific project.
When I did this however, I run into several problems.
C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v12.0\8.1\Microsoft.Windows.UI.Xaml.Common.targets(327,9): Xaml Internal Error error WMC9999: Object reference not set to an instance of an object.
This was fixable by rebuilding the project. However, a new error appeared:
CSC : error CS5001: Program ‘c:\Work\Demos\DemoApp\obj\Debug\intermediatexaml\DemoApp.exe’ does not contain a static ‘Main’ method suitable for an entry point
Everything looked good, but whatever I tried the error still persisted. Eventually, I figured it out that the build action for the App.xaml file was wrong. When the files where included in the project, App.xaml was added as a simple Page.
However, this is not a regular page, it’s an application definition and the build action must be manually changed accordingly.
When you make this change and rebuild again (a simple build won’t suffice) everything works fine again.
This tutorial saved my life! Thank you!
Thanks, had this problem too and had no idea what to do about that, this solution solved it.
I had imported in a new UWP project an App.xaml file from an old one. I struggled with this error for almost an hour until I found this post. As soon as I read the title a light fired in my head. Thank you!