为什么 ' ',十六进制值 0x0C,是一个无效字符。第 1 行,位置 1。抛出 WPF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14352651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 07:03:19  来源:igfitidea点击:

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

wpfxamlparseexception

提问by BalaKrishnan?

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 框架中时,它会引发错误' ', hexadecimal value 0x0C, is an invalid character. Line 1, position 1.如何找到导致问题的原因。当 xxxx.XAML 位于另一个项目的起始页面时,它工作正常,当我在另一个项目中加载 xxxx.XAML 的内容时,意味着它会引发错误,为什么会发生这种情况?

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

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

采纳答案by BalaKrishnan?

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。所以它导致了问题

回答by XMight

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();