Posts Tagged ‘Error’

Error when Trying to Run an WPF Program: XamlParseException occurred

August 4, 2011

PROBLEM:

image

This error is a very difficult one to identify.  It took me a couple of hours and remembering what code I added within the last compile.  Note:  This error does not occur when you compile, but when you run the application. 

What it turns out to be is when you write the following XAML code for a Window Form in WPF (Windows Presentation Foundation). 

The error was on Line number 14 but not line position 9… as the above error display shows.

Code Snippet
  1. <Window
  2.     x:Name="PullDraftDetail"
  3.     x:Class="PullDraftDetail"
  4.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  5.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
  6.     AllowsTransparency="True"
  7.         Title=""
  8.          mc:Ignorable="d"
  9.         xmlns:d="http://schemas.microsoft.com/expression/blend/2008&quot;
  10.         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
  11.         d:DesignHeight="200" d:DesignWidth="700"
  12.         SizeToContent="WidthAndHeight"
  13.         WindowStartupLocation="CenterScreen"
  14.         WindowStyle="None" Background="{x:Null}" Icon="/PullDraft_WPF;component/images/Book_JournalwPen.ico"
  15.     >

This code produces the following form in “Design View”.
image 

What I wanted is to make the Window transparent and display the “GroupBox" and all the other elements by setting the Window’s “Background=”{x:Null}”

But, when I added the “Icon=”/PullDraft_WPF;component/images/Book_JournalwPen.ico” I got the error “XamlParseException occurred”.  By the way… I did not need the “Icon” element because the Window was transparent anyway.

Solution:

I removed the Icon element and everything ran fine. 

Code Snippet
  1. <Window
  2.     x:Name="PullDraftDetail"
  3.     x:Class="PullDraftDetail"
  4.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  5.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
  6.     AllowsTransparency="True"
  7.         Title=""
  8.          mc:Ignorable="d"
  9.         xmlns:d="http://schemas.microsoft.com/expression/blend/2008&quot;
  10.         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
  11.         d:DesignHeight="200" d:DesignWidth="700"
  12.         SizeToContent="WidthAndHeight"
  13.         WindowStartupLocation="CenterScreen"
  14.         WindowStyle="None"
  15.         Background="{x:Null}"
  16.         >

…End of Line…

Advertisements