The reason why you have this issue is because your previous version is still running in the background. And because it's still running Visual Studio can't remove it's .exe in order to replace it with the new version.
Why is you previous version still running?
You've provided this code:
private void Student_btn(object sender, EventArgs e)
{
SignUp signup = new SignUp();
signup.Show();
this.Hide();
}
Let's assume that this method is part of your MainWindow
. When the user clicks the button, the MainWindow opens a new window signup.Show()
and hides itself this.Hide()
.
But that means, that your MainWindow
is still running, you just can't see it and it will still be running after you close the new window.
To resolve the problem you have to close the MainWindow
properly. And you can do it like that:
private void Student_btn(object sender, EventArgs e)
{
SignUp signup = new SignUp();
this.Hide(); //Your MainWindow hides itself and gets invisible
signup.ShowDialog(); //You code will "stop" here until the new window is closed
this.Close() //You MainWindow closes itself and your program will stop
}
If you want to resume to your MainWindow
when the new window closes. Use this.Show()
instead of this.Close()