title: C# - Restarting application conflicts with "program already running" error
body: <p>When I call the Application.Restart() method, the error comes up that detects whether the application is currently running.  Is there anyway around this?</p>
  
  <pre><code>    static void Main(string[] args)
      {
          string proc = Process.GetCurrentProcess().ProcessName;
          Process[] processes = Process.GetProcessesByName(proc);
          if (processes.Length &gt; 1)
          {
              MessageBox.Show("Program is already running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
          else
          {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              Application.Run(new Form1());
          }
      }
  </code></pre>