private static void DebuggerPresent() { bool isDebuggerPresent = false; NativeMethod.CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref isDebuggerPresent); if (isDebuggerPresent) { throw new InvalidOperationException($"Cannot run {ProductName} if Debugger is present."); } }