【发布时间】:2016-01-03 00:50:56
【问题描述】:
为我的 winform 自动生成的代码中发生了堆栈溢出。它仅发生在表单的自动生成代码的开头,而不是其中的任何控件。我尝试删除第一行,它发生在下一行。没有堆栈跟踪或内部异常,请帮助。
编辑
这是我的表单代码:
namespace Eternal_Continent
{
public partial class Almanac : Form
{
public Almanac()
{
InitializeComponent();
}
public List<string> Content = new List<string>();
private void Almanac_Load(object sender, EventArgs e)
{
timer1.Interval = 5000;
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(Application.StartupPath + "\\Resources\\font_name.ttf");
textBox1.Font = new Font(pfc.Families[0], 36);
}
private void Almanac_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
Hide();
}
}
}
这是设计师的:
namespace Eternal_Continent
{
partial class Almanac
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Almanac));
this.textBox1 = new System.Windows.Forms.TextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.Color.Khaki;
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(546, 582);
this.textBox1.TabIndex = 0;
//
// timer1
//
this.timer1.Enabled = true;
//
// Almanac
// I removed the autoscale lines here, because I wanted to see if it would still create errors, it did
this.BackgroundImage = Properties.Resources.Stone;
this.ClientSize = new System.Drawing.Size(546, 582);
this.Controls.Add(this.textBox1);
this.Icon = Properties.Textures.EternalContinent1;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Almanac";
this.Text = "Almanac";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Almanac_FormClosing);
this.Load += new System.EventHandler(this.Almanac_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.Dispose();
}
#endregion
private System.Windows.Forms.Timer timer1;
public System.Windows.Forms.TextBox textBox1;
}
}
编辑 #2 删除 Dispose() 行会导致
当前进程已使用其所有系统允许的窗口管理器对象句柄
在我的 Resources.Designer.cs 中。
【问题讨论】:
-
您是否更改/编辑了设计器代码?
-
没有一些代码可以参考,我能告诉你的最好的就是:你是否在某处创建了一个无限循环?
-
Plutonix,我这样做是因为我想看看它是否会持续抛出错误,但除此之外,不会。我删除了一行,看看它是否会继续发生。 Paul,据我所知,任何地方都没有循环,它是 VS 自动生成的代码。
-
保罗的意思是:你有没有创建任何无限递归(调用自身的方法)?请出示您自己和设计者的代码,以便我们了解发生了什么。
-
我现在上传了代码。