none
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll

    Question

  • Hi Guys,

    I am developing my first WP8 app. I am getting the following error:

    A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll

    What is the solution to rectify this exception.

    Thanks

    Tuesday, December 17, 2013 7:10 PM

Answers

  • Hi, mSpot Inc.

    Yes, you have exception in your code, because you need set

    Grid.Row="0"

    But no

    Grid.Row=" 0"

    Regards, Nikita


    • Edited by Nikita Bondarenko Saturday, December 21, 2013 11:16 AM
    • Marked as answer by Sujit Rai Saturday, December 21, 2013 6:41 PM
    Saturday, December 21, 2013 11:15 AM

All replies

  • Does the exception crash your app if you don't handle it?

    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.

    Tuesday, December 17, 2013 8:39 PM
    Moderator
  • I am running the app in visual studio. Just to learn i started this App (Calculator). Following is my MainPage.xaml and screenshot.

    <phone:PhoneApplicationPage
        x:Class="Calculator.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        FontFamily="{StaticResource PhoneFontFamilyNormal}"
        FontSize="{StaticResource PhoneFontSizeNormal}"
        Foreground="{StaticResource PhoneForegroundBrush}"
        SupportedOrientations="Portrait" Orientation="Portrait"
        shell:SystemTray.IsVisible="True">
    
        <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
            <!-- LOCALIZATION NOTE:
                To localize the displayed strings copy their values to appropriately named
                keys in the app's neutral language resource file (AppResources.resx) then
                replace the hard-coded text value between the attributes' quotation marks
                with the binding clause whose path points to that string name.
    
                For example:
    
                    Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
    
                This binding points to the template's string resource named "ApplicationTitle".
    
                Adding supported languages in the Project Properties tab will create a
                new resx file per language that can carry the translated values of your
                UI strings. The binding in these examples will cause the value of the
                attributes to be drawn from the .resx file that matches the
                CurrentUICulture of the app at run time.
             -->
    
            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock Text="My Calculator" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
                <TextBlock Text="CALCULATOR" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
    
            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="80"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBox Name="txtArea" FontSize="16" FontWeight="Bold" FlowDirection="RightToLeft" InputScope="Number" IsReadOnly="True" />
                <Grid x:Name="ContentPanel1" Grid.Row="2" Margin="12,0,12,0">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Button Name="btnSqrt" BorderBrush="DarkBlue" Content="Sqrt."/>
                    <Button Name="btnSquare" BorderBrush="DarkBlue" Content="x2" Grid.Row="0" Grid.Column="1"/>
                    <Button Name="btnModulo" BorderBrush="DarkBlue" Content="%" Grid.Row=" 0" Grid.Column="2"/>
                    <Button Name="btnPlus" BorderBrush="DarkBlue" Content="+" Grid.Column="3"/>
                    <Button Name="btnSeven" BorderBrush="DarkBlue" Content="7" Grid.Row=" 1"/>
                    <Button Name="btnEight" BorderBrush="DarkBlue" Content=" 8" Grid.Row=" 1" Grid.Column=" 1"/>
                    <Button Name="btnNine" BorderBrush="DarkBlue" Content="9" Grid.Row="1" Grid.Column=" 2"/>
                    <Button Name="btnMinus" BorderBrush="DarkBlue" Content="-" Grid.Row=" 1" Grid.Column=" 3"/>
                    <Button Name="btnFour" BorderBrush="DarkBlue" Content=" 4" Grid.Row=" 2"/>
                    <Button Name="btnFive" BorderBrush="DarkBlue" Content="5" Grid.Row=" 2" Grid.Column="1 "/>
                    <Button Name="btnSix" BorderBrush="DarkBlue" Content=" 6" Grid.Column=" 2" Grid.Row=" 2"/>
                    <Button Name="btnMuliply" BorderBrush="DarkBlue" Content="*" Grid.Column=" 3" Grid.Row=" 2"/>
                    <Button Name="btnOne" BorderBrush="DarkBlue" Content="1" Grid.Row=" 3"/>
                    <Button Name="btnTwo" BorderBrush="DarkBlue" Content=" 2" Grid.Row=" 3" Grid.Column="1"/>
                    <Button Name="btnThree" BorderBrush="DarkBlue" Content=" 3" Grid.Row=" 3" Grid.Column ="2"/>
                    <Button Name="btnDevide" BorderBrush="DarkBlue" Content="/" Grid.Row="3" Grid.Column="3"/>
                    <Button Name="btnDblZero" BorderBrush="DarkBlue" Content=" 00" Grid.Row=" 4"/>
                    <Button Name="btnZero" BorderBrush="DarkBlue" Content="0" Grid.Column=" 1" Grid.Row="4"/>
                    <Button Name ="btnDot" BorderBrush="DarkBlue" Content="." Grid.Column=" 2" Grid.Row=" 4"/>
                    <Button Name="btnEqual" BorderBrush="DarkBlue" Content="=" Grid.Row=" 4" Grid.Column=" 3"/>
                 </Grid>
                </Grid>
    
            <!--Uncomment to see an alignment grid to help ensure your controls are
                aligned on common boundaries.  The image has a top margin of -32px to
                account for the System Tray. Set this to 0 (or remove the margin altogether)
                if the System Tray is hidden.
    
                Before shipping remove this XAML and the image itself.-->
            <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
        </Grid>
    
    </phone:PhoneApplicationPage>


    Saturday, December 21, 2013 8:30 AM
  • Hi, Sujit Rai.

    Give us message of exception please.

    And I see small mistakes in you xaml:

     - You wrong set Grid.Row property when set it in Grid.Row=2, because numbering starts with 0 (you need Grid.Row=1)

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

    - Recheck Grid.Row property and Grid.Column property in other cases (Buttons etc.)

    And XamlParseException often occurred when app can't find any resources.

    Regards, Nikita.



    Saturday, December 21, 2013 9:02 AM
  • I copy and pasted your xaml into a page, and saw the error happen. If you look at the error details, it says:

        System.Windows.Markup.XamlParseException occurred
          HResult=-2146233087
          Message=Failed to create a 'System.Int32' from the text ' 0'. [Line: 71 Position: 86]

    This is line 71 of your xaml (in the code editor, the bottom right shows the line/column of the cursor):
        <Button Name="btnModulo" BorderBrush="DarkBlue" Content="%" Grid.Row=" 0" Grid.Column="2"/>

    The error is subtle and unexpected. You wrote Grid.Row=" 0" (with a space in front of the 0). You need to remove the space: Grid.Row="0". It is odd that the designer preview accepts the space but the runtime does not. You need to go through all of your Grid.Column and Grid.Row values and make sure that none of them have embedded spaces.


    Richard Woo
    Saturday, December 21, 2013 10:06 AM
  • Hi, mSpot Inc.

    Yes, you have exception in your code, because you need set

    Grid.Row="0"

    But no

    Grid.Row=" 0"

    Regards, Nikita


    • Edited by Nikita Bondarenko Saturday, December 21, 2013 11:16 AM
    • Marked as answer by Sujit Rai Saturday, December 21, 2013 6:41 PM
    Saturday, December 21, 2013 11:15 AM
  • Thanks Nikita it worked. It was a blank space issue.

    • Edited by Sujit Rai Saturday, December 21, 2013 6:43 PM
    Saturday, December 21, 2013 6:42 PM
  • You Should Set Your element As You Should put your elements inside the Grid and if You have more than Grid You should set element inside grid for example you can put grid inside grid and So on
    Thursday, February 20, 2014 8:58 AM