What is this error? DisconnectedContext

2

Galera blz?

I'm here programming for Windows Form with C # when I run into a "DisconnectedContext" error.

Well let me explain how my program works, I have several forms in a project, where I have to make the transition between these forms, for example one form is the Login form and the other is a "Lesson plan" for example .

In the transition from the "Login" form to the "Lesson Plan" Form in the "Lesson Plan" builder I get this exception.

Basically the statement is as follows, when I click the login button the system authenticates the teacher, right after everything happens (authenticated teacher), I pass an instruction where I instantiate a thread and pass a method on it, close the Form "Login" for the opening of the other form "Class Plan".

Here's the photo:

Herearethecodes:

1-Clickingloginbutton

privatevoidBtn_Entrar_Click(objectsender,EventArgse){stringlogin=txbLogin.Text;stringsenha=txbSenha.Text;if(string.IsNullOrEmpty(login)||string.IsNullOrEmpty(senha)){MessageBox.Show("Não pode haver campo(s) vazio(s)");
            return;
        }


        if (login.Contains("'"))
        {
            MessageBox.Show("Não é permitido usar caracteres no login");
            return;
        }
        if (senha.Contains("'"))
        {
            MessageBox.Show("Não é permitido usar caracteres '  na senha");
            return;


        }



         professor = new Professor();


        if ((professor.Codigo = professor.autenticarProfessor(login, senha))                   != null)
        {
            professor.bindProfessor(login, professor);    

            this.Close(); //Fecho esta tela
            this.Dispose(); //Dispose nela
            th = new Thread(abrirTela_Plano_Aula); //Abro uma nova linha de 
            th.SetApartmentState(ApartmentState.STA);
            th.Start();
        }
        else {

            MessageBox.Show("Dados incorretos");
            return;
        }
    }

2 - Method that opens the other form

    private void abrirTela_Plano_Aula()
    {
        Application.Run(new Plano_Aula(professor)); //Aqui chamo a nova tela

    }

3 - Classroom Builder Here I make checks if the teacher has a photo  if it does not, I go to the bank and look for a photo for teachers without a photo

    public Plano_Aula(Professor professor)
    {
        this.professor = professor;
        InitializeComponent();
        //Foto professor logado
        imgProfessor.ImageLocation = professor.FotoProfessor;
        imgProfessor.SizeMode = PictureBoxSizeMode.StretchImage;

        if (string.IsNullOrEmpty(professor.FotoProfessor))
        {
            if (professor.Sexo == "M")
            {
                professor.FotoProfessor = new ConfigurarImagemSistema().getImg("fotoAlunoDesconhecido", "M", "chamada");
                imgProfessor.ImageLocation = professor.FotoProfessor;

            }
            else if (professor.Sexo == "F")
            {
                professor.FotoProfessor = new     ConfigurarImagemSistema().getImg("fotoAlunaDesconhecido", "F", "chamada");
                imgProfessor.ImageLocation = professor.FotoProfessor;

            }

        }
    
asked by anonymous 03.10.2015 / 20:19

0 answers