为什么我的简单页面导航失败并出现TargetInvocationException?

时间:2012-12-26 19:25:35

标签: c# navigation winrt-xaml windows-phone-8 invocationtargetexception

我的应用程序在“Debugger.Break”失败了:

private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
    if (Debugger.IsAttached)
    {
        // A navigation has failed; break into the debugger
        Debugger.Break();
    }
}

...我得到:“ System.Reflection.TargetInvocationException未处理 消息:System.Windows.ni.dll中出现未处理的“System.Reflection.TargetInvocationException”类型异常

到目前为止,我的代码非常简单。我只是在主页面上有一个HyperlinkBut​​ton,试图导航到另一个页面:

//winrt-xaml:
        <HyperlinkButton x:Name="hyperlinkButtonManageInvitations" Margin="24" Grid.Row="1" Tap="HyperlinkButtonManageInvitations_OnTap">Manage Invitations</HyperlinkButton>

// C#代码隐藏:

private void HyperlinkButtonManageInvitations_OnTap(object sender, GestureEventArgs e)
{
    NavigationService.Navigate(
        new Uri("//TaSLs_Pages/InvitationManagePage.xaml", UriKind.Relative));
}

我确实使用Resharper将MainPage.xaml(和* .cs)移动到我的TaSLs_Pages子文件夹中;这不会有问题,不是吗?

1 个答案:

答案 0 :(得分:1)

检查NavigationFailedEventArgs。您可以通过e.Exception.Message

检查异常