簡體   English   中英

“對象”不包含“處置”的定義

[英]'object' does not contain a definition for 'Dispose'

protected override void Dispose(bool disposing)

在上面的行中,我遇到了錯誤。

錯誤是:

windowformapplication.form1.Dispose(bool): not suitable method found to override

1)您可能已經將class Form class Form1重命名為class Form1而沒有重命名設計器文件,即Partial class Form.designer.cs改為Partial class Form1.designer.cs
2)您的InitializeComponent(); 會在windowformapplication.form1()構造函數中刪除或添加注釋。

或嘗試在designer.cs中添加以下代碼。

 /// <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);
    }

確保您的Form1.cs從Form擴展。 例如公共局部類Form1:Form {..}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM