XamlReader.Load(XmlReader)“堆栈为空” Xaml解析异常
我正在尝试在运行时加载 xaml 文件。 我的代码如下所示:
StringReader stringReader = new StringReader(xamlString);
XmlReader xmlReader = XmlReader.Create(stringReader);
content = XamlReader.Load(xmlReader);
它基本上是 msdn 的复制粘贴。 XamlReader.Load 行抛出 XamlParseException,并带有“Stack Empty at line....”的内部异常。
它指向的行是在 xaml 字符串中找到的用户控件的结束标记,即该字符串的最后一行。
基本的 Xaml 结构如下,
<UserControl>
<UserControl.Resources>
</UserControl.Resources>
<Grid>
</Grid>
</UserControl>
谷歌搜索没有找到任何结果。 非常感谢任何帮助找到解决方案的帮助。
I'm trying to load a xaml file at runtime. My code looks like this:
StringReader stringReader = new StringReader(xamlString);
XmlReader xmlReader = XmlReader.Create(stringReader);
content = XamlReader.Load(xmlReader);
It's basically copy paste of of msdn. the XamlReader.Load line throws a XamlParseException with an inner exception of "Stack Empty at line....".
The line it points to is the closing tag of the user control found in the xaml string, the last line of the string.
The basic Xaml structure is as follows
<UserControl>
<UserControl.Resources>
</UserControl.Resources>
<Grid>
</Grid>
</UserControl>
Googling didn't turn anything up. Any help in find a solution is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚开始从 xaml 中删除块,直到错误消失。 我能够将其范围缩小到在用户控件声明中找到的这一行,
不完全确定为什么会抛出 Stack Empty 异常,但确实如此。
这是整个标题,其中罪魁祸首以粗体显示
I just started chopping blocks out of my xaml until the error went away. I was able to narrow it down to this line found in my user control declaration
Not exactly sure why that throws a Stack Empty exception, but it does.
Here is the entire Header with the culprit in bold