System.ObjectDisposedException: '无法访问已处理的对象

时间:2021-03-07 17:05:43

标签: c# mysql objectdisposedexception

所以我一直在关注一个关于如何使用 C# 和 MySQL 为 Visual Studio 重新创建学校出勤/登录系统的 YouTube 教程,当我尝试在文本框中输入或不输入任何内容的情况下登录时,我不断收到标题错误。这是我在主表单中的代码:

    private void MainForm_Load(object sender, EventArgs e)
    {
        //the code in MainForm_Activated was originally placed here but it gave the same error, so it was corrected
    }

    private void MainForm_Activated(object sender, EventArgs e)
    {
        //opens LoginForm alongside MainForm
        LoginForm newLogin = new LoginForm();
        newLogin.ShowDialog();

        //closes LoginForm if the username and password are incorrect
        if (newLogin.loginFlag == false)
        {
            Close();
        }
    }
}

}

在教程中,我注意到 MainForm_Activated 似乎只是出现在“已激活”下的“属性”窗口中,而我必须从头开始将其输入到同一个框中。 The picture is here.

这是教程本身,错误显示在 13:06:https://www.youtube.com/watch?v=Ck3cKCGevlM

0 个答案:

没有答案