Silverlight Error: AG_E_UNKNOWN_ERROR

I get AG_E_UNKNOWN_ERROR when starting my Silverlight project. The project is migrated from WPF, and from what I can build over the network, I assume this is due to something invalid in my XAML

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

Here is Generic.xaml, 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> 
+4
source share
6 answers

Recently a bunch of these have been debugged. When I don't see the problem, I simply comment on the large XAML snippet until I get the error, and then uncomment the parts until I find the place that throws the exception.

EDIT: First, get rid of the curly braces in TargetType="{c:CalendarTimeslotItem}" . Just tried it, and I get the exception that way. Just use TargetType="c:CalendarTimeslotItem"

+3
source

Set your system to break when throwing exceptions.

  • In Visual Studio, select the Debug menu, then Exceptions ....

  • In the Exceptions dialog box, select the Thrown check box next to Common Language Runtime Exceptions .

  • Run the project in the debugger (make sure Silverlight debugging is enabled).

Most likely, you will see some irrelevant exceptions that will be thrown (just continue debugging), but at some point you should see a XAML exception. Check the exception to see if you can determine the line number. If an exception is thrown in the code file, you can output the XAML file from the code file.

+2
source

I, too, was disappointed with this mistake, but the hint about commenting out the parts and doing it to narrow it down helped a lot. In the end, I found a bad binding to one of my controls. Therefore, if you get this, make sure your XAML is perfect before proceeding.

+1
source

We just had the same error, and the reason is that it was built for x86 instead of Any CPU. It is clear that this will not be every case, but I hope that this will help, since it certainly was ours.

+1
source

The problem is solved (And others arise, but what the next day)

In my case, using other limited properties in the template caused a problem.

  <Style TargetType="c:CalendarTimeslotItem"> <!--<Setter Property="Content" Value="{Binding}" />--> <Setter Property="Template"> 

and

  <Style TargetType="c:CalendarAppointmentItem"> <!--<Setter Property="StartTime" Value="{Binding StartTime}" />--> <!--<Setter Property="EndTime" Value="{Binding EndTime}" />--> <Setter Property="Template"> 
0
source

If you look closely, the error usually has a line number that refers to lines in XAML.

-2
source

All Articles