问题
I have a WPF application which runs perfectly fine on vista/7 but on Windows XP it chucks up the System.Windows.Markup.XamlParse error, and it's quite frustrating because I have a hell of a lot of controls in my application and I don't know what is causing the problem.
Can anyone shine some light here?
回答1:
In my case I had to change Source of Image element. It has ico file, but XP cannot have it as source for this type of element.
<Image Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="48" Height="48" VerticalAlignment="Center"
Source="Resources/Images/favicon.ico" />
I had to change it to and make specific PNG file
<Image Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="48" Height="48" VerticalAlignment="Center"
Source="Resources/Images/favicon-256.png" />
My error was:
Exception: Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception. PresentationFramework at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
回答2:
This is often caused by one of your control templates using something from the PresentationFramework.Aero assembly. This can happen if you modify templates by using "Edit a Copy" in Blend. This will generate a XAML copy of the currently active template for the system Theme under which Blend is running. In the case of Vista or Win7 that's Aero by default (Classic for XP). Many of the default Aero templates contain custom elements (ButtonChrome, etc.) that are specific to the Aero theme and declared in the Aero assembly. When running on XP the Aero assembly usually isn't available and so you get missing references in your XAML at runtime.
Do a text search on your whole solution for "PresentationFramework.Aero" and you should find some xmlns declarations using it.
来源:https://stackoverflow.com/questions/2481178/xamlparseexception-on-windows-xp