I can not find a resolution for this error

0

I have a program in C # and it is giving MANY different bugs , I'll send them all here, as follows:

Code Error: Description:

So let's go.

internal AcessoAdd()
{
    InitializeComponent();
}
  

Error: System.ComponentModel.Win32Exception: 'Error creating window handle.'

Correction: changed internal for public

Description: This code was already there, I tried to format the PC as recommended, tried to play in regedit and increase the amount of window identifiers allowed, but nothing works.

UsuarioForm usuForm = new UsuarioForm();
  

Error: System.StackOverflowException

Description: UserForm as the name itself says, is a form, I create a variable and then open it, but this error happens and I tried everything to make it work as well.

For the moment that's it, you'll probably get more after fixing this, but does anyone know how to answer these two?

User Code Form:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.Xml.Linq;
using System.Threading.Tasks;

namespace PecsCon
{
public partial class UsuarioForm
{

    public UsuarioAdd usuAdd = new UsuarioAdd();
    public AcessoAdd acAdd = new AcessoAdd();

    internal UsuarioForm()
    {
        InitializeComponent();
    }

    public string idgrid;
    public string funcidgrid;
    public string logingrid;
    public string senhagrid;
    public int deletadogrid;
    public int op;
    private void Usuario_Load(object sender, EventArgs e)
    {
        this.MdiParent = FormPrincipal.DefaultInstance;
        this.Dock = DockStyle.None;

        //variavel para utilizar a classe
        BancoUsuario bncusu = new BancoUsuario();

        rbTodos.Checked = true;
        //preenche o datagridview
        bncusu.PreencheDataGrid(DataGridViewUsu, op);



    }

    private void ButtonX4_Click(object sender, EventArgs e)
    {

        acAdd.Show();
        if (!string.IsNullOrEmpty(idgrid))
        {

            acAdd.cboxUsuario.SelectedValue = idgrid;

        }


    }

    private void usuCadastro_Click(object sender, EventArgs e)
    {

        usuAdd.add_update = 1;

        usuAdd.Show();


    }

    private void TextBox1_TextChanged(object sender, EventArgs e)
    {
        BancoUsuario bncusu = new BancoUsuario();

        bncusu.ProcuraTuplaUsu(ref DataGridViewUsu, procuraUsu, op);
    }

    private void rbDesativados_CheckedChanged(object sender, EventArgs e)
    {
        if (rbDesativados.Checked == true)
        {
            op = 2;


            //variavel para utilizar a classe
            BancoUsuario bncusu = new BancoUsuario();

            //preenche o datagridview
            bncusu.PreencheDataGrid(DataGridViewUsu, op);
        }
    }

    private void rbTodos_CheckedChanged(object sender, EventArgs e)
    {
        if (rbTodos.Checked == true)
        {
            op = 3;


            //variavel para utilizar a classe
            BancoUsuario bncusu = new BancoUsuario();

            //preenche o datagridview
            bncusu.PreencheDataGrid(DataGridViewUsu, op);
        }
    }

    private void rbAtivos_CheckedChanged(object sender, EventArgs e)
    {
        if (rbAtivos.Checked == true)
        {
            op = 1;


            //variavel para utilizar a classe
            BancoUsuario bncusu = new BancoUsuario();

            //preenche o datagridview
            bncusu.PreencheDataGrid(DataGridViewUsu, op);
        }
    }

    private void usuDeletar_Click(object sender, EventArgs e)
    {

        BancoUsuario bncusu = new BancoUsuario();

        bncusu.DeletaUsu(Convert.ToInt32(this.idgrid), op);

    }

    public void DataGridViewUsu_CellClick(object sender, DataGridViewCellEventArgs e)
    {

        if (e.RowIndex >= 0)
        {

            DataGridViewRow row = null;

            row = this.DataGridViewUsu.Rows[e.RowIndex];

            BancoUsuario bncusu = new BancoUsuario();



            idgrid = row.Cells["Id"].Value.ToString();
            funcidgrid = row.Cells["Id Funcionario"].Value.ToString();
            logingrid = row.Cells["Login"].Value.ToString();
            senhagrid = row.Cells["Senha"].Value.ToString();
            deletadogrid = Convert.ToInt32(row.Cells["Deletado"].Value);

        }

    }

    private void usuVizualizar_Click(object sender, EventArgs e)
    {

        BancoUsuario bncusu = new BancoUsuario();

        usuAdd.add_update = 2;

        bncusu.buscaUsu(Convert.ToInt32(idgrid), Convert.ToInt32(funcidgrid), ref logingrid, ref senhagrid, ref deletadogrid, ref usuAdd.NomeComboBox, ref usuAdd.loginText, ref usuAdd.senhaText, usuAdd.cbAtivo.Checked);

    }
}

}

    
asked by anonymous 09.06.2017 / 17:03

2 answers

0

Verify that you are importing the namespaces.

The classes UserAdd and AccessAdd both are in a different namespace than PecsCon .

If, for example, they are in a namespace named Users and Hits respectively, try this:

    using NomeDoProjeto.Usuarios;
    using NomeDoProjeto.Acessos;
    
09.06.2017 / 18:44
0

remove

internal UsuarioForm()

place

public  UsuarioForm()
    
12.06.2017 / 02:16