Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:26:30+00:00 2026-05-15T19:26:30+00:00

My C# Winform application encounters the situation where it cannot access a disposed object.

  • 0

My C# Winform application encounters the situation where it cannot access a disposed object. The disposed object is a form (frmQuiz) that is opened from a button on the login form.

The Situation:

My application typically has two or three forms open at the same time. The Program.cs file runs form frmLoginBackground, which is just a semi-transparent background that covers the computer screen. The load event for this form opens the second form, frmLogin, which includes a button that opens frmQuiz, which is a simple form with a few math questions on it.

The code in frmLogin that opens frmQuiz looks like this:

private void btnTakeQuizNow_Click(object sender, EventArgs e)
{
    frmQuiz quiz = new frmQuiz();
    quiz.TakeQuizNow("take_quiz_now", Convert.ToInt32(comboQuizMeNow.SelectedValue));  //Pass the form a quiz id number.
    quiz.Show();
}

When frmQuiz opens both it and frmLogin are open and accessible.

The frmLogin also contains a password control that opens the administration form by first opening frmSplash, which is a “Please Wait…” splash form based on a timer. The timer Tick event launches frmAdmin, which is the administration form. The code in frmLogin looks like this:

private void btnPasswordSubmit_Click(object sender, EventArgs e)
{
     //Password verification code snipped.

     frmSplash objSplash = new frmSplash();
     objSplash.Show();
   //this.Hide();
     this.Close();
}

And the code in frmSplash looks like this:

private void timer1_Tick(object sender, EventArgs e)
{
    frmAdmin objfrmAdmin = new frmAdmin ();
    objfrmAdmin.Show();
    this.Close();
}

When frmAdmin opens then frmLogin is no longer accessible; however, frmAdmin contains a ‘Return to Login Screen’ button with code like this:

private void btnReturnToLogin_Click(object sender, EventArgs e)
{
    exitWarnings("return_to_login");
}

private void exitWarnings(string action)
{
    //Warning message code snipped.

    if (action == "return_to_login")
    {
        frmLogin objLogin = new frmLogin();
        objLogin.Show();
    }
}

The frmLoginBackground remains open until the application exits.


The Problem:

Everything works fine when frmLogin first opens and the button is clicked to open frmQuiz. The quiz form opens a runs fine. However, after logging into the administration form (which closes or hides the login form) and then clicking the ‘Return to Login Screen’ link, then, after frmLogin reappears, the object disposed exception occurs when clicking the button to open frmQuiz. Visual Studio highlights in yellow the “quiz.Show();” line of code. The exception occurs regardless of weather I use “this.Close();” or “this.Hide();” in the btnPasswordSubmit_Click event.

Can anyone suggest a solution that allows me to open frmQuiz after returning to frmLogin from frmAdmin.

Cheers, Frederick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:26:31+00:00Added an answer on May 15, 2026 at 7:26 pm

    Since you create a new instance for quizz just before the quizz.Show() it cannot be quizz itself that throws the exception.

    Take a good look at the constructor and FormCreate event of frmQuiz. It looks like that is where the dead horse is being kicked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've developed a WinForm application that run in background. The main form is hidden
In my winform application; I have login form and main form. When I run
I have a winform application that goes with name myForm . Within this form
In winform application, how do I give a different (different from the blue one)
I have a winform application that contains a c# webbrowser control.Webbrower control load a
I have an c# winform application that runs under a local account but needs
My winform application periodically pulls a flash file from an SQL database, writes it
My winform application is having a DataGridView (DGV), I'm populating it from an xml
In my winform application I have a treeview. To give the idea that a
I am creating an winform application that will run on a tablet PC. One

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.