XAML Parsing Exception
Posted
by e28Makaveli
on Stack Overflow
See other posts from Stack Overflow
or by e28Makaveli
Published on 2010-03-08T23:55:58Z
Indexed on
2010/03/19
8:01 UTC
Read the original article
Hit count: 715
I have a simple XAML page that load fine when it is loaded as part of any application within Visual Studio. However, when I deploy this application using ClickOnce, I get the following exception:
Type : System.Windows.Markup.XamlParseException, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Message : Unable to cast object of type 'System.Windows.Controls.Grid' to type 'EMS.Controls.Dictionary.StatusBarControl'. Error at object 'System.Windows.Controls.Grid' in markup file 'EMS.Controls.Dictionary;component/views/statusbarcontrol.xaml'. Source : PresentationFramework Help link : LineNumber : 0 LinePosition : 0 KeyContext : UidContext : NameContext : BaseUri : pack://application:,,,/EMS.Controls.Dictionary;component/views/statusbarcontrol.xaml Data : System.Collections.ListDictionaryInternal TargetSite : Void ThrowException(System.String, System.Exception, Int32, Int32, System.Uri, System.Windows.Markup.XamlObjectIds, System.Windows.Markup.XamlObjectIds, System.Type) Stack Trace : at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType) at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException) at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord) at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord) at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() at System.Windows.Markup.TreeBuilder.Parse() at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at EMS.Controls.Dictionary.StatusBarControl.InitializeComponent() at EMS.Controls.Dictionary.StatusBarControl..ctor(IDataView content) at OCC600.ReportManager.ReportPresenter.ShowQueryView(Object arg, Boolean bringForward, Type selectedDataType) at OCC600.ReportManager.ReportPresenter..ctor(IUnityContainer container) at OCC600.ReportManager.Module.Initialize() at Microsoft.Practices.Composite.Modularity.ModuleLoader.Initialize(ModuleInfo[] moduleInfos)
Inner Exception
---------------
Type : System.InvalidCastException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Unable to cast object of type 'System.Windows.Controls.Grid' to type 'EMS.Controls.Dictionary.StatusBarControl'.
Source : EMS.Controls.Dictionary
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void System.Windows.Markup.IComponentConnector.Connect(Int32, System.Object)
Stack Trace : at EMS.Controls.Dictionary.StatusBarControl.System.Windows.Markup.IComponentConnector.Connect(Int32 connectionId, Object target)
at System.Windows.Markup.BamlRecordReader.ReadConnectionId(BamlConnectionIdRecord bamlConnectionIdRecord)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
The XAML page is given below:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cdic="clr-namespace:EMS.Controls.Dictionary.Primitives"
xmlns:dicutil="clr-namespace:OCC600.Infrastructure.Dictionary.Utility;assembly=EMS.Infrastructure.Dictionary"
Loaded="ResultSetControl_Loaded">
<StatusBarItem Margin="10,0, 10, 0">
<TextBlock Text="{Binding CountText}" Padding="5,0"/>
</StatusBarItem>
<StatusBarItem Margin="10,0">
<TextBlock Text="{Binding MemoryUsageText}" Padding="5,0"/>
</StatusBarItem>
<StatusBarItem Margin="10,0" MaxWidth="400">
<TextBlock Text="{Binding StatusReport.Summary}" Padding="5,0" />
</StatusBarItem>
<ProgressBar Margin="20,0" Name="progBar" Width="150" Height="13" Visibility="Collapsed" >
<ProgressBar.ContextMenu>
<ContextMenu Name="ctxMenu" ItemsSource="{Binding ActiveWorkItems}"
Visibility="{Binding Path=ActiveWorkItems.HasItems, Converter={StaticResource BooToVisConv}}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<StackPanel Height="20" Margin="10,0" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Text="{Binding Path=Name, Mode=OneTime}"
Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Left" />
<ToggleButton Style="{StaticResource vistaGoldenToggleButtonStyle}"
Padding="5,0" Content="Cancel" IsChecked="{Binding Cancel}"
Margin="10,0,0,0" >
</ToggleButton>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</ProgressBar.ContextMenu>
</ProgressBar>
<StatusBarItem Margin="10,0" MaxWidth="400" HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Last Update:" Padding="5,0" />
<TextBlock Text="{Binding TimeStamp}" Padding="5,0" />
</StackPanel>
</StatusBarItem>
<!-- TODO: Put checkmark if all is well, or error if connection failed-->
<StatusBarItem Style="{DynamicResource {ComponentResourceKey
TypeInTargetAssembly=dc:Ribbon, ResourceId=StatusBarItemAlt}}"
DockPanel.Dock="Right" Padding="6,0,32,0" >
<cdic:SplitButton Margin="5,0" Padding="5,2"
Style="{DynamicResource {ComponentResourceKey
TypeInTargetAssembly={x:Type cdic:SplitButtonResources}, ResourceId=vistaSplitButtonStyle}}"
Mode="Split">
<cdic:SplitButton.ContextMenu>
<ContextMenu >
<MenuItem Header="Refresh Now" Command="{Binding ToggleConnectivityCmd}"
CommandParameter="false"/>
<MenuItem IsCheckable="True"
IsChecked="{Binding ConnectState, Converter={StaticResource isFailedConverter}}"
CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=IsChecked}"
Header="Work Offline" Command="{Binding ToggleConnectivityCmd}"/>
</ContextMenu>
</cdic:SplitButton.ContextMenu>
<cdic:SplitButton.Content>
<StackPanel Orientation="Horizontal">
<Image
x:Name="img"
Source="{Binding ConnectState, Converter={StaticResource imageConverter}}"
Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{Binding ConnectState}" Padding="3,0,0,0"/>
</StackPanel>
</cdic:SplitButton.Content>
</cdic:SplitButton>
</StatusBarItem>
</StatusBar>
</Grid>
The error just seems to have come out of no where. Any ideas?
TIA.
© Stack Overflow or respective owner