为什么'',十六进制值0x0C是无效字符。第1行,第1位。引发WPF

时间:2022-09-20 18:30:55

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 ?

当我将xxxx.XAML加载到WPF帧时,它会抛出错误'',十六进制值0x0C,是一个无效字符。第1行,第1位。如何找到导致问题的原因。当xxxx.XAML在另一个项目的起始页面时,它工作正常,当我在另一个项目中加载xxxx.XAML的意思时,它会抛出一个错误,为什么会发生这种情况?

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

我还将我的项目从vs 2010升级到vs 2012

2 个解决方案

#1


7  

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:

在我的情况下,我想使用下面的代码加载XAML文件,但它的Build Action设置为Page而不是Resource:

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

#2


3  

In my file name, i have upper case X. while reading load the file i use small x. so it cause the problem

在我的文件名中,我有大写X.在阅读加载文件我使用小x。所以它导致了问题

#1


7  

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:

在我的情况下,我想使用下面的代码加载XAML文件,但它的Build Action设置为Page而不是Resource:

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

#2


3  

In my file name, i have upper case X. while reading load the file i use small x. so it cause the problem

在我的文件名中,我有大写X.在阅读加载文件我使用小x。所以它导致了问题