Why the ' ', hexadecimal value 0x0C, is an invalid character. Line 1, position 1. throws in WPF

BalaKrishnan웃 picture BalaKrishnan웃 · Jan 16, 2013 · Viewed 7k times · Source

When i load a xxxx.XAML into WPF frame it throws the error ' ', hexadecimal value 0x0C, is an invalid character. Line 1, position 1. how to find which is causing the problem. when the xxxx.XAML is in another project's start page, it works fine, when i load that condent of xxxx.XAML in arother project means it throws an error why this is happening ?

And also i upgrade my project from vs 2010 to vs 2012

Answer

XMight picture XMight · Jul 23, 2013

In my case it was that I wanted to load a XAML file using the code below, but it's Build Action was set to Page instead of Resource:

Uri uri = new Uri(resourcePath, System.UriKind.Relative);
Stream stream = Application.GetResourceStream(uri).Stream;
UIElement view = (UIElement)XamlReader.Load(stream);
stream.Close();