locked
Failed to assign to property 'Windows.UI.Xaml.Controls.ContentPresenter.Content'

    Question

  • I am developing a Windows Store app using the new universal app stuff (I am not including a phone project currently). Intermittently at run time I get a Windows.UI.Xaml.Markup.XamlParseException with the message Failed to assign to property 'Windows.UI.Xaml.Controls.ContentPresenter.Content'.

    The key here is this is intermittent, I can run the app many times with no issue and then suddenly it will happen & if I restart it seldom if ever happens immediately afterwards. It only shows up at runtime.

    In terms of environment, on every page I have a custom content control which we use to set the chrome for the page, so that it is uniform and also so we can handle popups etc... The XAML for that control is at:http://pastebin.com/T6KNWhxy

    The issue occurs on most pages, however the camera page (XAML at http://pastebin.com/azdQ33Y2) seems to have it happen far more often.

    It also happens when running normally (i.e. without debugging). Loading up the dump file from that crash has the following error (which matches the details in the event log):

    Unhandled exception at 0x7582B152 (combase.dll) in triagedump.dmp: 0xC000027B: An application-internal exception has occurred (parameters: 0x055C31F8, 0x00000004).

    I have tried:

    Any suggestions on what could be causing it?

    Exception details

    {"XAML parsing failed."}
    [Windows.UI.Xaml.Markup.XamlParseException]: {"XAML parsing failed."}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    HResult: -2144665590
    InnerException: null
    Message: "XAML parsing failed."
    Source: null
    StackTrace: null
    TargetSite: null

    Robert MacLean - www.sadev.co.za

    Tuesday, September 2, 2014 12:38 PM

Answers

  • Hi

    I did manage to solve it, so I am guessing you have the latest code from GitHub which is why it is working now. If you are so inclined the commit 9df49eafa073d049b5b8f2a0583693f9c6400f9a will show you the error. With that you seldom get beyond 50.


    Robert MacLean - www.sadev.co.za

    Wednesday, September 10, 2014 12:40 PM

All replies

  • Hi Robert,

    The error message tells "Failed to assign to property 'Windows.UI.Xaml.Controls.ContentPresenter.Content", we have to look into the code, what has been set as the Content.

    I looked into your first link, seems there are four ContentPresenter in XAML, let's say could we remove them one by one to see which one is the root cause for the exception?

    But it looks like strange to me from your code, in link2 you define the content of the PageLayout control, but in link1 you re-define it again in the template, and you even binding the whole content to the ContentPresenter, I'm not sure why do you want to do this?

                                  <ContentPresenter Grid.Row="2" Grid.Column="2" Width="1260" Height="690"  Content="{TemplateBinding Content}">
                                        <ContentPresenter.Transitions>
                                            <TransitionCollection>
                                                <EntranceThemeTransition />
                                            </TransitionCollection>
                                        </ContentPresenter.Transitions>
                                    </ContentPresenter>

    This is the content you are going to bind:

            <Grid Background="Black" Margin="-335,-195,-325,-195">
                <CaptureElement Name="capturePreview" />
                <Viewbox Width="{Binding IDBookOverlayWidth}" Visibility="{Binding ShowIDBookOverlay, Converter={StaticResource BoolToVis}}">
                    <Grid Width="600">
                        <Rectangle Width="600" Height="825.6" StrokeDashArray="2.5" HorizontalAlignment="Left" VerticalAlignment="Top" Stroke="#7FFFFFFF" StrokeThickness="5" />
                        <Rectangle Width="528" Height="124.8" StrokeDashArray="2.5"  Margin="32,32,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Stroke="#7FFFFFFF" StrokeThickness="5" />
                        <Rectangle Width="244" Height="266.8" StrokeDashArray="2.5" Margin="32,0,0,32" VerticalAlignment="Bottom" HorizontalAlignment="Left" Stroke="#7FFFFFFF" StrokeThickness="5" />
                    </Grid>
                </Viewbox>
                <Button HorizontalAlignment="Left" Margin="79,79,0,0" Style="{StaticResource BackButton}" Command="{Binding GoBack}" />
                <Button Click="TakePhoto" Style="{StaticResource NoAnimationButton}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,70,0" Width="200" Height="200" Padding="0" Background="Transparent">
                    <Grid>
                        <Ellipse Fill="White" Width="200" Height="200" />
                        <Path Data="M31.478432,15.239C36.687607,15.239 40.906941,19.457997 40.906941,24.661992 40.906941,29.865988 36.687607,34.085986 31.478432,34.085986 26.279251,34.085986 22.059918,29.865988 22.059918,24.661992 22.059918,19.457997 26.279251,15.239 31.478432,15.239z M31.425879,9.8389888C23.416933,9.8389888 16.88777,16.362975 16.88777,24.379973 16.88777,32.394988 23.416933,38.916991 31.425879,38.916991 39.444832,38.916991 45.963986,32.394988 45.963986,24.379973 45.963986,16.362975 39.444832,9.8389888 31.425879,9.8389888z M43.904202,0C45.124008,-2.9131115E-08,46.113869,0.98797598,46.113869,2.205993L46.113869,4.8519898C46.113869,4.9059749,46.103981,4.9589839,46.103981,5.013L49.523449,5.013C51.613137,5.013,53.333,6.7279964,53.333,8.8219905L53.333,39.297972C53.333,41.392973,51.613137,43.108,49.523449,43.108L3.8095522,43.108C1.7198642,43.108,0,41.392973,0,39.297972L0,8.8219905C0,6.7279964,1.7198642,5.013,3.8095522,5.013L5.6292574,5.013C5.6192486,4.9459834,5.6192486,4.8799739,5.6192486,4.8109741L5.6192486,3.6089783C5.6192486,1.836975,7.0491121,0.40100091,8.8188965,0.40100085L22.057127,0.40100085C23.826912,0.40100091,25.266663,1.836975,25.266663,3.6089783L25.266663,4.8109741C25.266663,4.8799739,25.256653,4.9459834,25.246645,5.013L41.71455,5.013C41.70454,4.9589839,41.70454,4.9059749,41.70454,4.8519898L41.70454,2.205993C41.70454,1.8799743,41.774479,1.5699767,41.904465,1.2909849L41.904465,1.2019956 41.9445,1.2019956C42.314446,0.48999017,43.054337,-2.9131115E-08,43.904202,0z" Stretch="Uniform" Fill="{StaticResource PrimaryRedColourBrush}" Width="110" Height="110" />
                    </Grid>
                </Button>
            </Grid>
    

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Wednesday, September 3, 2014 9:03 AM
    Moderator
  • "I'm not sure why do you want to do this?" - I think you have misunderstood the links.

    Link1 is the XAML for the custom ContentControl we use on every page, which I suspect is related to the cause.

    Link2 is the XAML for a page where I use the custom control defined in link 1. 

    The reason for doing this is so that I can use the control on every page and replace the content. So link1 isn't redefining anything. 

    "there are four ContentPresenter in XAML, let's say could we remove them one by one to see which one is the root cause for the exception?" - If you look at link2, we are only setting one of them. Would the others be affected if they are not set?


    Robert MacLean - www.sadev.co.za

    Wednesday, September 3, 2014 9:25 AM
  • I've been able to create a version of the app which causes this to happen in a very reproducible way 

    https://github.com/rmaclean/HeatherSpeedApp


    Robert MacLean - www.sadev.co.za

    Friday, September 5, 2014 11:27 AM
  • Hi Robert - I'm on my third run of your app.  On the first run, I went to #419 but the app hung at that point - not a crash.  On the second, I went over 5000 iterations with no problem, but I was attached with Windbg rather than VS, so I restarted with VS again.  I am over 4000 iterations now with no problem.  How often are you seeing the problem with your app?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    Friday, September 5, 2014 4:45 PM
    Moderator
  • I went over 12000 iterations with no crash.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 8, 2014 2:22 PM
    Moderator
  • Hi

    I did manage to solve it, so I am guessing you have the latest code from GitHub which is why it is working now. If you are so inclined the commit 9df49eafa073d049b5b8f2a0583693f9c6400f9a will show you the error. With that you seldom get beyond 50.


    Robert MacLean - www.sadev.co.za

    Wednesday, September 10, 2014 12:40 PM