将对象图写入XAML时出现StackOverFlow异常

时间:2010-12-31 11:50:06

标签: c# xaml stack-overflow

我正在尝试将对象流写入XAML文件,但我最终在StackoverFlowException中。 在CallStack中,我可以看到“已超出Visual Studio支持的最大堆栈帧数”

这是我正在尝试执行的一段代码。

StreamWriter xamlStream =new StreamWriter(File.OpenWrite("a.xaml"));
string myXaml = System.Windows.Markup.XamlWriter.Save(objectInstance);
xamlStream.Write(myXaml);

谢谢......!

1 个答案:

答案 0 :(得分:2)

必须是objectInstance包含循环引用,而你的编写者不支持它们。