简体   繁体   English

“对象”不包含“处置”的定义

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

protected override void Dispose(bool disposing)

In the line above I am getting an error. 在上面的行中,我遇到了错误。

The Error is: 错误是:

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

1)You might have renamed your class Form to class Form1 without renaming your designer file ie Partial class Form.designer.cs to Partial class Form1.designer.cs 1)您可能已经将class Form class Form1重命名为class Form1而没有重命名设计器文件,即Partial class Form.designer.cs改为Partial class Form1.designer.cs
2)Your InitializeComponent(); 2)您的InitializeComponent(); would have deleted or commented in your windowformapplication.form1() constructor. 会在windowformapplication.form1()构造函数中删除或添加注释。

Or try adding following code in your designer.cs. 或尝试在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);
    }

Be sure that your Form1.cs extend from Form. 确保您的Form1.cs从Form扩展。 Such as public partial class Form1 : Form{..} 例如公共局部类Form1:Form {..}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM