在我需要添加功能之前,我有这条线工作:
public MainForm()
{
InitializeComponent();
refreshUI();
}
然后我需要在显示 MainForm 之前显示一个welcomeBox 几秒钟。所以我改变了这样的代码:
System.Threading.Timer timer;
GUI.WelcomeBox welcomeBox;
public MainForm()
{
this.Visible = false;
//Showing welcome box
welcomeBox = new GUI.WelcomeBox();
welcomeBox.Visible = true;
this.Visible = false;
timer = new System.Threading.Timer(new System.Threading.TimerCallback(delayedActions),null,5000,2000);
}
private void delayedActions(object o)
{
welcomeBox.Visible = false;
welcomeBox.Close();
timer.Dispose();
InitializeComponent();
// this line is unreachable, because of error
refreshUI();
}
但发生错误InitializeComponent()
:问题事件名称:CLR20r3
Problem Signature 01: todoweeklyshedule.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 4fc5385b
Problem Signature 04: System.Windows.Forms
Problem Signature 05: 4.0.0.0
Problem Signature 06: 4ba1e14e
Problem Signature 07: a11
Problem Signature 08: 1b
Problem Signature 09: System.ArgumentException
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033
Additional Information 1: a1ee
Additional Information 2: a1ee2874cedcaa72f2a8419ddd18697e
Additional Information 3: a319
Additional Information 4: a319510eabcccf7de47b58017b885ff3
顺便说一句,MainForm 将与this.Visible = false;
行一起显示。我打电话给 MainForm()Application.Run(new MainForm());
是这个原因吗?