StackOverflowException

StackOverflowException

本文介绍了StackOverflowException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我收到此类型为System.StackOverflowException的未处理的异常"的错误.

我有一个具有&的Rule类设置mailto和rating的属性.
另外,我正在将值写入XML文件.因此,在写入XML文件时,我具有该代码.该错误是由于递归函数而发生的,但我似乎无法修复它.

代码:

Hello,

I am getting this "An unhandled exception of type ''System.StackOverflowException'' occurred error.

I have a Rule class which has get & set properties for mailto and rating.
Plus, I am writing values to an XML file. So while writing to the XML file I have that code. the error is happening because of the recursive function but I cant seem to fix it.

The code:

for (int i = 0; i < this.lvRules.Items.Count; i++)
           {
               newnode.SelectSingleNode("Mailto").InnerText = lvRules.Items[i].SubItems[1].Text;
               newnode.SelectSingleNode("Rating").InnerText = lvRules.Items[i].SubItems[0].Text;
               Rule rule = new Rule();
               rule._mailto = lvRules.Items[i].SubItems[1].Text;
               rule._rating = Convert.ToInt32(lvRules.Items[i].SubItems[0].Text);
               List<Rule> Rules = new List<Rule>();
               Rules.Add(rule);
               MessageBox.Show(Rules.Count().ToString());
           }

推荐答案


这篇关于StackOverflowException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 10:17