2

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?

itowlson
  • 73,686
  • 17
  • 161
  • 157
Sandeep Bansal
  • 6,280
  • 17
  • 84
  • 126
  • 1
    Look at the inner exception, and please include all of the information from the inner exception (including any nested inner exceptions)... – Reed Copsey Mar 19 '10 at 23:43
  • Agreed, since the XAML won't have changed between XP and 7, this is likely to be a "false" XamlParseException where it's the window class constructor throwing an error. Look especially for a TargetInvocationException and drill into its InnerException(s). – itowlson Mar 19 '10 at 23:47
  • Sorry guys but how do I get to the inner exception? – Sandeep Bansal Mar 20 '10 at 01:56
  • This happened to me the other day... It was because one of my project folders had an ampersand (&) in the folder name. I'm not submitting this as an answer because I still no nothing about your exception yet. – Brent Mar 20 '10 at 01:59
  • 1
    OK I tried a try - catch on the InitializeComponent and it's just chucking out errors to do with all the effects that I used. How can I fix this? – Sandeep Bansal Mar 20 '10 at 02:04
  • You can get to the InnerException by stopping in the debugger in the catch block, and using the Watch window or the Exception Assistant. Or just dump out the Exception.ToString(): that will include the InnerException, but you'll need to grovel through a lot of stack trace to get to it. – itowlson Mar 20 '10 at 02:43

2 Answers2

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)
Evalds Urtans
  • 6,436
  • 1
  • 41
  • 31
1

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.

John Bowen
  • 24,213
  • 4
  • 58
  • 56
  • Hi thanks for the reply, I did the search and nothing came up in the whole solution with the PresentationFramework.Aero ... I've changed colors for textboxes that's about it, I don't know what else to do. – Sandeep Bansal Mar 20 '10 at 18:50
  • "I don't know what else to do." As discussed in comments to the question: post the exception information. – itowlson Mar 20 '10 at 20:17
  • OK I installed both blend and vs 2010 in a XP VM and got the Exception it's producing.The file is located at: http://www.sinvise.net/stacktrace.txt – Sandeep Bansal Mar 20 '10 at 22:14
  • It looks like the Exception is coming from trying to create an icon for the window. Are you setting Icon on your Window? – John Bowen Mar 21 '10 at 23:22