我不小心從我的項目之一去除引用,然後小心翼翼地把它們放回,但現在我扔在代碼中的錯誤將被完全正常,所以我想我一定還是會丟失,除非參考在這個過程中有其他東西被打破了。下面是電流誤差:的Visual Studio Express的2010和參考文檔版本
The variable 'button1' is either undeclared or was never assigned.
但這裏是Form1.Designer.cs代碼:
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
...
//
// button1
//
this.button1.Location = new System.Drawing.Point(235, 382);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(125, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Generate Report";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
...
this.Controls.Add(this.button1);
...
private System.Windows.Forms.Button button1;
最後七個線全部拋出這個錯誤。任何建議表示讚賞。
問候。
編輯:這裏是相關的評論代碼:
public partial class Severity3RetailNetworkTrackingLog : Form
{
public Severity3RetailNetworkTrackingLog()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
凡Form1中已更改爲Severity3RetailNetworkTrackingLog。
聽起來像Button1的不宣。應該有一行:Button Button1; – RedEyedMonster 2012-07-26 14:52:36
這不是你引用一個問題,或者你會得到相關嘗試使用類型的按鈕,而不是一個實例相關的異常的異常。你似乎錯過了你的Button聲明。 Button button1 = new Button(); – CSharpened 2012-07-26 14:57:36