Wpf – Silverlight Error: AG_E_UNKNOWN_ERROR

silverlightwpf

I'm getting a AG_E_UNKNOWN_ERROR when running my Silverlight project. The project is ported from WPF, and from what I can gather around the web, I'd assume it's related to something invalid in my XAML

EDIT C# Control sources can be found here: SilverlightCalendar/Controls

Here's Generic.xaml, the styles for my application.

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:SilverlightCalendar.Controls">

    <Style TargetType="{c:CalendarTimeslotItem}">
        <Setter Property="Content" Value="{Binding}" />
        <Setter Property="Background" Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{c:CalendarTimeslotItem}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="#A5BFE1"
                            BorderThickness="0,0.5,0,0.5"
                            x:Name="bd"
                            Height="22">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{c:CalendarLedgerItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{c:CalendarLedgerItem}">
                    <Border Background="#E3EFFF"
                            BorderBrush="#6593CF"
                            BorderThickness="0,0,1,1"
                            Height="44" Width="50">
                        <StackPanel Orientation="Horizontal" 
                                    VerticalAlignment="Center" 
                                    HorizontalAlignment="Center">
                            <TextBlock Text="{TemplateBinding TimeslotA}" 
                                       Foreground="#9493CF" FontSize="16" Margin="0,3,0,0"/>
                            <TextBlock Text="{TemplateBinding TimeslotB}" 
                                       Foreground="#9493CF"  Margin="1.5,0,0,0"/>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{c:CalendarDay}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <c:TimeslotPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{c:CalendarDay}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <StackPanel x:Name="PART_CalendarTimeslots" />
                            <ItemsPresenter />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{c:CalendarLedger}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{c:CalendarLedger}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <StackPanel x:Name="PART_CalendarLedgerItems" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{c:Calendar}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{c:Calendar}">
                    <Border Background="#E3EFFF"
                            BorderBrush="#6593CF"
                            BorderThickness="2,2,2,2">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Border BorderBrush="#6593CF" BorderThickness="0,0,0,1" 
                                    Grid.Column="0" Grid.Row="1" />
                            <Border BorderBrush="#6593CF" BorderThickness="0,0,0,1" 
                                    Grid.Column="1" Grid.Row="1" />
                            <ScrollViewer Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="50" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <c:CalendarLedger Grid.Column="0" />
                                    <c:CalendarDay Grid.Column="1" x:Name="PART_CalendarDay" />
                                </Grid>
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{c:CalendarAppointmentItem}">
        <Setter Property="StartTime" Value="{Binding StartTime}" />
        <Setter Property="EndTime" Value="{Binding EndTime}" />
        <Setter Property="Width" Value="{Binding ActualWidth, ElementName=CalendarTimeslots}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{c:CalendarAppointmentItem}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="300" />
                            <ColumnDefinition Width="300" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" 
                                Grid.Column="{Binding Column}" 
                                Grid.ColumnSpan="{Binding ColumnSpan}"
                                CornerRadius="4,4,4,4" 
                                BorderThickness="1,1,1,1" 
                                BorderBrush="#5D8CC9" 
                                Background="{Binding Background}"
                                Margin="1,1,5,1" 
                                Padding="5,5,5,5">
                            <Border.Effect>
                                <DropShadowEffect Opacity="0.5" />
                            </Border.Effect>
                            <TextBlock 
                                IsHitTestVisible="False"
                                Foreground="{Binding Foreground}"
                                VerticalAlignment="Top"
                                MaxHeight="20"
                                LineHeight="20"
                                FontFamily="Segoe UI" 
                                FontSize="12.75" 
                                FontWeight="DemiBold"
                                FontStretch="Medium"
                                TextWrapping="WrapWithOverflow"
                                Text="{Binding Subject}" />                            
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

Best Answer

Recently debugged a bunch of these. When I can't see the problem I just comment big chunk of the XAML until I don't get the error and then uncomment parts until I can find a spot causing the exception.

EDIT: for starters get rid of curly brackets in TargetType="{c:CalendarTimeslotItem}". Just tried and I get the exception this way. Just use TargetType="c:CalendarTimeslotItem"

Related Topic