用这句试试: (System.Diagnostics.Process.GetCurrentProcess().ProcessName != "devenv") 转载于:https://www.cnblogs.com/Don/archive/2008/06/12/1218398.html