Unknown build error for WPF xmlns definition

I was recently working on a WPF application using the excellent WPF Toolkit when I ran across a strange build error in Visual Studio:

Unknown build error, ”clr-namespace:System.Windows.Controls.DataVisualization.Charting;  assembly=System.Windows.Controls.DataVisualization.Toolkit’ mapping URI is not valid.

The offending line of source code looks like this [edited for readability]:

  1. <Window
  2.    x:Class="Constructor.MainWindow"
  3.    xmlns ="http://schemas.microsoft.com/winfx/2006/…&quot;
  4.    xmlns:x="http://schemas.microsoft.com/winfx/2006/…&quot;
  5.    xmlns:y="clr-namespace:S.C;  assembly=S.W.C.DV.T"
  6.    xmlns:z="clr-namespace:S.C;  assembly=S.W.C.DV.T"
  7.    Title ="MainWindow" Height="350" Width="912"  
  8.    >

As you can see, I used white space to align blocks of text within the snippet. On lines 5 and 6 this was particularly useful because it allows for a  quick visual comparison of the assembly portion of these lines. Unfortunately, herein lies the problem.

A quick Bing search found the MSDN documentation for XAML Namespaces and Namespace Mapping for WPF XAML. This was an interesting read, explaining the meaning of attributes like x:Class as well as the purpose of the ever-present default xmlns and xmlns:x namespaces. In addition, the documentation alludes to the cause of my build error:

do not include any whitespace anywhere in the declaration.

My assumption that whitespace indenting within the xmlns attributes of the Windows tag was incorrect. Whitespace is interpreted as invalid input and causes compilation to fail.

I hope my post helps you resolve the cryptic Unknown build error!

Leave a comment