为什么从HyperlinkBut​​ton导航到Internet导致我的应用程序崩溃?

时间:2012-11-24 01:40:16

标签: hyperlink windows-8 winrt-xaml windows-store-apps

我正在尝试使用HyperlinkBut​​ton从设置弹出窗口显示隐私声明;但是,在单击超链接后,我遇到了两个对话框崩溃。最顶层的人说:

~~~~~~~~~~~~~~~~~~~~~~~~
Warning
A debugger is attached to <ProjectName> but not configured to debug this  
unhandled exception. To debug this exception, detach the current debugger.
~~~~~~~~~~~~~~~~~~~~~~~~

...而且在第二个对话框下面是:

~~~~~~~~~~~~~~~~~~~~~~~~
Visual Studio Just-In-Time Debugger
An unhandled win32 exception occurred in <ProjectName> [10704].

Possible Debuggers:
New instance of Microsoft Visual Studio 2012
            Yes No
~~~~~~~~~~~~~~~~~~~~~~~~

当我选择“No”来启动那个新实例时,我被从模拟器转移回我的调试会话 - 实际上,调试会话已经终止 - 就好像我有Shift + F5'd。

我的XAML是:

<HyperlinkButton Grid.Row="4" Grid.ColumnSpan="2" Content="Duckbilled Platypi Privacy Statement" NavigateUri="http://montereyscenics.posterous.com"/>

更新

因为链接在AppSettings示例中工作正常,我在Onlink中添加了一个OnTapped事件(不可否认,这与OnClicked不同),现在看起来像这样:

<HyperlinkButton Grid.Row="4" Grid.ColumnSpan="2" Content="Time and Space Lines Privacy Statement" NavigateUri="http://montereyscenics.com/" Tapped="PrivacyHyperlink_OnTapped"/>

...和处理程序:

async void PrivacyHyperlink_OnTapped(object sender, TappedRoutedEventArgs e)
{
    await Windows.System.Launcher.LaunchUriAsync(new Uri(((HyperlinkButton)sender).Tag.ToString()));
}

它工作了一秒钟 - 它立即打开了页面。但随后它在处理程序中的“await”行(唯一的行)上崩溃了,带有这样的信息:

“* System.NullReferenceException未被用户代码处理   的HResult = -2147467261   Message =对象引用未设置为对象的实例。   来源= MetroSandboxPlaypen   堆栈跟踪:        在MetroSandboxPlaypen.TandSLsSettings.d__0.MoveNext()in ... *“

0 个答案:

没有答案