StackOverflowException错误 [英] StackOverflowException error

查看:105
本文介绍了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());
           }

推荐答案

无疑,此错误是针对递归编程的.这实际上是在编程控制进入无限循环时发生的.按断点检查它,然后您将看到它永远不会停止,因为它不能满足于停止它.对于相同的对象,可以无限次地重用,并且没有足够的空间来容纳新值并引发此错误.只需检查您正在使用的数据即可.

谢谢
Definitely this error is for recursive programming. It is actually happen when programming control get into infinity loop. Check it by break point then you can see it will never stop because it does not meet to true to stop it. As for same object reused unlimited time and that does not have enough space to hold new value and throws this error. Just check your data that your are using.

Thanks


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆