Prevent multiple instances of C# application - 100% working

If you only want 1 (one) instance of your C# application running, then simply make use of the following code in the Form1 (or whatever you form is called) constructor, just after InitializeComponent();

if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
    MessageBox.Show(“Only one instance allowed”);
    Environment.Exit(0); //exits the application
}
else
{

//load windows forms application if this is the only instance

}

Have fun and happy coding!