c# - 打开共享ui后Windows Phone 8.1应用程序崩溃

标签 c# crash windows-phone-8.1

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

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

当我使用Visual Studio将应用程序部署到手机上时,它不会崩溃,但是随后运行该应用程序(没有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).

页面的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>

问题是什么?

最佳答案

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

最好的办法是尝试调试挂起的事件-为此,请使用VS中的“生命周期事件”选项卡(如this answer中的图片所示)。

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

关于c# - 打开共享ui后Windows Phone 8.1应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28961050/

相关文章:

c# - 是否可以将 BackgroundWorker 类与 .net 核心一起使用?

css - 如何理解这个崩溃报告? SIGSEGV

iphone - UIAnimation 导致 XCode 在一段时间后崩溃

windows - 如何将点击事件添加到来自通知中心的 Toast 通知?

c# - 接口(interface)实现中成员的返回类型必须与接口(interface)定义完全匹配?

c# - 使用C#调用Oracle函数时出现字符串缓冲区太小错误

C# 从 Firefox 获取 URL 但不使用 DDE

ios - UIAlertView 关闭时崩溃

c# - Windows Phone 8.1 VibrationDevice 不会停止振动

javascript - Windows Phone 8.1 本地存储无法工作