Valerie Meunier

Valerie Meunier

  • 1.7k
  • 398
  • 16.1k

Could not copy "obj\Debug\WindowsFormsApp2.exe" to "bin\Debug\WindowsF

Jan 10 2022 4:13 PM

Hi

I made this code to go from one form to another and come back. First it works, but after a while, if i do Build or Rebuild or Clean, i get this:

Error: Could not copy "obj\Debug\WindowsFormsApp2.exe" to "bin\Debug\WindowsFormsApp2.exe". Exceeded retry count of 10. Failed. The file is locked by: "WindowsFormsApp2 (12944)". Any idea?

Thanks

public partial class Form1 : Form
    {
        internal static int x, y=5;
        public Form1()
        {
            InitializeComponent();
            ActiveControl = textBox1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            x = Convert.ToInt32(textBox1.Text);
            Hide();
            Form2 frm2 = new Form2();
            frm2.ShowDialog();
        }
    }

------

 public partial class Form2 : Form
    {
        int prod;

        public Form2()
        {
            InitializeComponent();
            label4.Text = Form1.x.ToString();
            label5.Text = Form1.y.ToString();
            prod = Convert.ToInt32(label4.Text) * Convert.ToInt32(label5.Text);
            label7.Text = prod.ToString();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            Form1 frm1 = new Form1();
            frm1.ShowDialog();
            this.Close();
        }
 


Answers (3)