Windows Universal Apps: “The page name does not have an associated type in namespace, Parameter name: pageToken”
June 6, 2015 Leave a comment
When building Universal Windows Apps, and using Prism to compose the application, you would have changed your App.xaml.cs class to something like this:
public sealed partial class App : MvvmAppBase { #region Private fields private readonly IUnityContainer container; #endregion #region Constructors public App() { this.InitializeComponent(); container = new UnityContainer(); } #endregion #region Overrides of MvvmAppBase class protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args) { NavigationService.Navigate("Main", null); return Task.FromResult<object>(null); } #endregion #region Unity Container methods protected override Task OnInitializeAsync(IActivatedEventArgs args) { container.RegisterInstance<INavigationService>(NavigationService); ViewModelLocationProvider.SetDefaultViewModelFactory((viewModelType) => container.Resolve(viewModelType)); return base.OnInitializeAsync(args); } #endregion }
But when you try to run your application you would get the error The page name does not have an associated type in namespace, Parameter name: pageToken
The reason is simple :). Your MainPage (and all views for that matter) needs to be inside the Views folder inside your project and not in the root. This applies to both Windows and Windows Phone app projects.