我的Windows手机应用程序在加载主页时冻结。我在主构造函数上设置了断点,它触发了OnNavigatedTo事件但从未触发“已加载”事件。它通过构造函数中的InitializeComponent()获取。它会显示启动画面和主页应用栏,但此时会冻结。
我最近重构了我的主命名空间,导致主页无法加载。我通过启动对象修复了它。
在重构之前一切正常。
我应该包含哪些代码?这个项目相当大,所以我不知道你真的希望我发布代码多少。
任何想法??
答案 0 :(得分:2)
好的,我发现了问题。在App.Xaml.cs中,我犯了以下重要错误:
这是我的代码:
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
{
// Set the root visual to allow the application to render
if (RootVisual != null && RootVisual != RootFrame)
RootVisual = RootFrame;
// Remove this handler since it is no longer needed
RootFrame.Navigated -= CompleteInitializePhoneApplication;
}
以下是应该是:
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
{
// Set the root visual to allow the application to render
if (RootVisual != RootFrame)
RootVisual = RootFrame;
// Remove this handler since it is no longer needed
RootFrame.Navigated -= CompleteInitializePhoneApplication;
}
Resharper认为最好先检查RootVisual是否为空。令人难以置信的恼人的错误,因为它只会挂在启动PNG并且从不加载,显然是因为RootVisual没有设置。
答案 1 :(得分:0)
我之前遇到过这样的困难。听起来这可能是你的XAML中的一个问题,但实际上没有你的解决方案很难说。
以下是您可以尝试的一些事项:
如果您遇到异常,但未与代码中的特定点相关联:
希望这有帮助!