using System.Diagnostics; using System.IO; using System.Reflection.Assembly; class Class { if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(GetEntryAssembly().Location)).Count() > 1) { Process.GetCurrentProcess().Kill(); } }