创建表单对象时出错 [英] Error during create form object

查看:77
本文介绍了创建表单对象时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用使用方法在另一个表单对象中创建一个表单对象时,在调试时(而不是在构建时)得到了这种类型的错误:

When i create one form object in another from for using method I get this type of erro at Debug time not built time:

An unhandled exception of type 'System.StackOverflowException' occurred in Hart_Mon.exe


中 我不知道为什么会出现此错误,因此任何人都可以帮忙.

这是一些代码


I don''t know why this error accrue can any one help.

Here is some code

public void ComportChild(string no)
        {
            TreeNode[] Comportnode = treeView1.Nodes.Find(po.ToString(), true);
           
            TreeNode[] treeCol = po.Nodes.Find(no.ToString(), true);
            if (treeCol.Length > 0)
            {

            }
            else
            {
                TreeNode po1 = po.Nodes.Add(no.ToString());
            }
        }


我想以另一种形式使用此代码,所以我创建了对象,但是当我创建对象时,却以另一种形式遇到了该错误.
让我简单地解释一下.我的项目中有多种形式,一个类文件定义了许多方法.现在假设我有Form1和Form2,我想在Form1中创建上述代码,现在我想在Form2中使用此方法,所以当我在Form2中创建Form1对象时,它会在运行时在我创建Form2对象的类文件中给出错误. > 像这样的错误:


I want to use this code in another form so i create object but when i create object i got that error in another form.
Let me explain briefly. I have many form in my project and one class file at where i define many method. Now suppose i have form1 and form2 i create above code in form1 now i want to use this method in form2 so when i create form1 object at form2 then it give error at run time in class file at where i create form2 object.
Error like this:

An unhandled exception of type ''System.StackOverflowException'' occurred in Hart_Mon.exe

推荐答案

通常会在无限循环中创建对象时发生这种情况(例如,当您在方法主体内部调用一个方法时,那是不间断的递归调用).
Usually this happens when you''re creating objects in a infinite loop (when you, for instance, call one method inside the method body itself, that is unstopped recursive call).


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

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