Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winrt apps, unhandled exception at random occasions

During the development I experience unhandled exceptions at random occasions, but mostly after closing the application. Setting all options on 'break on exceptions' does not trigger any code. Anyone who experience the same behaviour. I am developing on the release preview build and visual studio RC build.

Screenshot unhandled exception

like image 619
markwilde Avatar asked Feb 20 '23 04:02

markwilde


1 Answers

First steps I did to resolve the problem is to:

  • Enable native debugging in the project properties (Debug tab, debugger type) (thnx James! I know now what you mean :-) )
  • Set symbol server to the right location (tools, options, Debugging, Symbols, all modules)

And start debugging. This will take a few minutes to start to load all symbols....

I traced it down to several exceptions when binding to an Bitmap of which the URL did not resolve. The binding was of a GridView to the SmallImageSource bitmap property of a class. When debugging this will give an exception in native code, but doesn’t trace to the output window or give an exception in the application. Eventually my application crashed… After fixing these resources my application did not crash anymore. Although this is not reproducible in a small scenario. Below a small bit of application code on which it crashed. the GridView was embedded in a SemanticZoom control

XAML (used in a semanticzoom control)

            <GridView.ItemTemplate>
                <DataTemplate>
                    <Grid Background="Gray" Width="300" Height="80">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding Group.Key.SmallImageSource}" Stretch="Uniform" Margin="15" Grid.Column="0"/>
                        <TextBlock Text="{Binding Group.Key.Name}" Margin="0,10" TextAlignment="Center" Grid.Column="1" VerticalAlignment="Center"/>
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>

C# (here is an URI which does not resolve to a local resource)

public Uri SmallImage
    {
        get
        {
            return new Uri("ms-appx:///Resources/Images/SubCategories/" + Id + "_" + FunctionHelper.StripCharacter(Name) + ".png", UriKind.Absolute);
        }

    }
    public BitmapImage SmallImageSource
    {
        get
        {
            return new BitmapImage(SmallImage);
        }
    }
    }
like image 139
markwilde Avatar answered Mar 04 '23 23:03

markwilde