积极答复者
Failed to create initial page

问题
-
An exception of type 'System.Exception' occurred in AskedToKnowDictionary.exe but was not handled in user code
Additional information: Failed to create initial page
If there is a handler for this exception, the program may be safely continued.
请帮忙看看问题出在哪里?
在运行的时候发生的。
protected override void OnLaunched(LaunchActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { if (!rootFrame.Navigate(typeof(MainPage), args.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
全部回复
-
您好:
如Jesse所说,出现异常是因为找不到MainPage页面,您可以检查下您的App是否包含这个页面,或者您可以换其它页面试下,看是否出现异常!
正如大家所说,问题确实出在首页导航上。
具体来看,是首页的构造函数中的initialize()方法定义总是出问题。我在其他程序里也遇到类似的问题,也有出现构造函数中的initialize()方法定义丢失的情况。
我的解决办法是,将程序里所有的文件重新编辑。但是,MainPage.xaml文件最后编辑。
最终可以解决问题,但是,我不明白为什么。
难道说,构造函数中的initialize()方法不能重载吗?