user3263192
user3263192

Reputation: 499

Windows phone 8.1 application crashing just after opening share ui

I have 2 pages in my windows 8.1 application. Both of them have a share button. On the first page which is my home page the share button works as it is suppossed to, i.e. open share ui (shown below).

But on my other page (which is has a webview for showing some modified web content) as soon as the share ui opens the app crashes (sometimes before opening). I am not getting any exceptions or errors during execution of program.

When I deploy the app to my phone using Visual Studio it does not crash, but on running the app afterwards (without visual studio) it starts crashing.

This shows how I open share UI (Find Full Code for the page here)

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

This is some part of the output when compiling (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 code for the page

    <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>

What is the problem?

Upvotes: 0

Views: 1117

Answers (1)

Romasz
Romasz

Reputation: 29792

There is probably a problem with suspending (it's not called when you are debugging).

The best would be if you have tried to debug your suspending events - to do it use Lifecycle events tab in VS (like in the picture in this answer.

The problem may be also that you have passed some parameters when navigating to page that are not serializable. In this case, when the app is being suspended, the SuspensionManager may throw exception.

Upvotes: 3

Related Questions