5
Answers

System.StackOverflowException when closing my form

george

george

16y
8.3k
1

hi  i close my form and serial port with a button

 

private void button1_Click(object sender, EventArgs e)

{

if (serialPort1.IsOpen) serialPort1.Close();

Close();

}

 

and with the X button in form

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

if (serialPort1.IsOpen) serialPort1.Close();

Close();

}

 

but some times have problem and i get System.StackOverflowException

i dont know why?

 

 

 

 

Answers (5)