Windows Phone 8.1应用程序在打开共享ui后崩溃

时间:2015-03-10 10:17:24

标签: c# crash windows-phone-8.1

我的Windows 8.1应用程序中有2页。他们俩都有一个分享按钮。 在作为我的主页的第一页上,共享按钮按照它的方式工作,即打开共享ui(如下所示)。

但是,在共享ui打开应用程序崩溃时(有时在打开之前),在我的其他页面(显示一些已修改的Web内容的webview)上。我没有在程序执行期间遇到任何异常或错误。

当我使用Visual Studio将应用程序部署到我的手机时,它不会崩溃,但之后运行应用程序(没有可视工作室)它会开始崩溃。

这显示我如何打开共享UI(Find Full Code for the page here

try
{
   Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
}
catch(Exception ex)
{
   //Code to handle exception
}

这是编译(find full output here

时输出的一部分
The thread 0x9ac has exited with code 259 (0x103).
The thread 0xca4 has exited with code 0 (0x0).
The thread 0xa80 has exited with code 259 (0x103).
The thread 0xc80 has exited with code 259 (0x103).
The thread 0xc44 has exited with code 259 (0x103).
The thread 0xcd8 has exited with code 259 (0x103).
The thread 0x8ec has exited with code 259 (0x103).
The thread 0xbac has exited with code 0 (0x0).
A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.ni.dll
The program '[2308] DATAPACKAGEHOST.EXE' has exited with code 1 (0x1).
The program '[1952] DATAPACKAGEHOST.EXE' has exited with code 1 (0x1).
The thread 0xc34 has exited with code 259 (0x103).
The thread 0xc78 has exited with code 259 (0x103).

Share UI

页面的Xaml代码

    <Grid.RowDefinitions>

        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <!-- Page title -->

    <ProgressBar 
        Width="400" 
        Height="40" 
        Foreground="Black" 
        VerticalAlignment="Top" 
        IsIndeterminate="True" 
        Grid.Row="0"
        Canvas.ZIndex="10" 
        x:Name="Progress_content"        
        Visibility="Collapsed"/>
    <Grid x:Name="grid" Grid.Row="0" 
              VerticalAlignment="Top" 
              Visibility="Collapsed"
              Background="{StaticResource HeadingBackground }" 
              Canvas.ZIndex="1">
        <TextBlock Text="Data could not be updated at the moment" 
                x:Name="Update_Error"
                Margin="15,0"
                Height="0"
                VerticalAlignment="Center"
                FontSize="15"
                Visibility="Collapsed"
                Foreground="White" 
                TextWrapping="WrapWholeWords"
                FontFamily="{StaticResource TextBlockFontFamily}" Canvas.ZIndex="1"/>
    </Grid>
    <WebView Grid.Row="0" NavigationStarting="Browser_NavigationStarting" 
             x:Name="in_app_browser" 
             NavigationCompleted="Browser_NavigationCompleted"
             NavigationFailed="Browser_NavigationFailed" 
             LoadCompleted="Nav_Complete" GotFocus="Hide_Error"/>
    <ad:AdControl 
            x:Name="adDuplexAd" 
            AdUnitId="122875"
            AppKey="ed3d918f-ba50-4702-a5eb-a12cad42b9de" 
            Grid.Row="1"
            />
</Grid>

<Page.BottomAppBar>

    <CommandBar Background="{StaticResource AppBarBackground}" >
        <AppBarButton x:Name="Refresh" Label="Refresh" Click="Refresh_Posts" Icon="Refresh"/>

        <AppBarButton x:Name="Share" Label="Like" Click="Share_Click">
            <AppBarButton.Icon>
                <BitmapIcon UriSource="ms-appx:///Assets/Share.png" Height="20" Width="20"/>
            </AppBarButton.Icon>
        </AppBarButton>

        <CommandBar.SecondaryCommands>
            <AppBarButton x:Uid="AboutButton" Label="about" Click="AboutPage"/>

        </CommandBar.SecondaryCommands>

    </CommandBar>

</Page.BottomAppBar>

有什么问题?

1 个答案:

答案 0 :(得分:3)

挂起可能存在问题(调试时未调用)。

最好的情况是,如果您尝试调试暂停事件 - 要在VS中使用生命周期事件标签(如this answer中的图片所示。

问题还可能是您在导航到不可序列化的页面时传递了一些参数。在这种情况下,当应用程序被暂停时, SuspensionManager 可能会抛出异常。