我想退出应用程序,但发生此错误 [英] i want to exit from application but occur this error

查看:90
本文介绍了我想退出应用程序,但发生此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

hello

namespace Mizan
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());









private void frmMain_Load(object sender, EventArgs e)
        {
            Application.ExitThread();






我想退出应用程序,但发生此错误:
无法访问已处置的对象.对象名称:"frmMain".






i want to exit from application but occur this error:
Cannot access a disposed object. Object name: ''frmMain''.

推荐答案

代替Application.ExitThread(),只需使用Close()
这将关闭frmMain实例并终止应用程序.
Instead of Application.ExitThread() just use Close()
That will close the frmMain instance and terminate the application.


private void frmMain_Load(object sender, EventArgs e)
        {
         Application.ExitThread();
         frmCsarresid f2 = new frmCsarresid();    f2.ShowDialog();



我连续评论:问题已解决



i comment a row: The problem was solved

private void frmMain_Load(object sender, EventArgs e)
        {
         Application.ExitThread();
         //frmCsarresid f2 = new frmCsarresid();    f2.ShowDialog();</pre>


这篇关于我想退出应用程序,但发生此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆