Mat*_*ux1 2 .net c# inheritance winforms
我一直在尝试实现和调整我的编码风格,更多的是程序编程风格,但在尝试运行另一个使用系统注册表的类时遇到了问题.此外,代码在主类中工作正常.PS我来自一个脚本背景.
代码错误:System.Windows.Forms.dll中出现类型为"System.StackOverflowException"的未处理异常
我已经从主应用程序中删除了代码,以便更容易找到问题.
主要表格类别:
public partial class Form1test : Form
{
// An unhandled exception of type 'System.StackOverflowException'
// occurred in System.Windows.Forms.dll
public Form1test()
{
TestClass lsr = new TestClass();
lsr.chkRegAct();
InitializeComponent();
}
}
Run Code Online (Sandbox Code Playgroud)
识别TestClass:
class TestClass : Form1test
{
//rest of code
}
Run Code Online (Sandbox Code Playgroud)
TestClass源于Form1Test.
您创建一个新的TestClass导致调用基类(的构造Form1Test)生成一个新的TestClass,这导致调用基类的构造函数(Form1Test)生成一个新的TestClass,这导致调用基类的构造函数(Form1Test)生成一个新的TestClass其结果调用基类(Form1Test)的构造函数生成一个新的TestClass结果,调用基类(Form1Test)的构造函数生成一个新的TestClass结果,调用基类(Form1Test)的构造函数生成一个新的TestClass结果调用构造函数base class(Form1Test)生成一个new TestClass,结果调用base class(Form1Test)的构造函数,生成一个new TestClass,调用base class(Form1Test)的构造函数生成一个new TestClass,结果调用base class(Form1Test)的构造函数产生.....
StackOverflowException由于无限递归导致的大量函数调用.
| 归档时间: |
|
| 查看次数: |
505 次 |
| 最近记录: |