Error when Trying to Run an WPF Program: XamlParseException occurred

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…

Tags: , , ,

One Response to “Error when Trying to Run an WPF Program: XamlParseException occurred”

  1. Blondell Says:

    Excellent goods from you, man. I have understand your stuff previous to and you are just
    extremely fantastic. I really like what you’ve acquired here, really like what you are stating and the way in which you say it.

    You make it enjoyable and you still care for to keep it sensible.
    I cant wait to read far more from you. This is actually
    a tremendous site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: