简体   繁体   中英

What is the best way in c# to determine whether the programmer is running the program via IDE or it's user?

在c#中确定程序员是通过IDE还是用户运行程序的最佳方法是什么?

if (System.Diagnostics.Debugger.IsAttached) {
    // You are debugging
}
public static bool IsInVisualStudio
{
    get
    {
        bool inIDE = false;
        string[] args = System.Environment.GetCommandLineArgs();
        if (args != null && args.Length > 0)
        {
            string prgName = args[0].ToUpper();
            inIDE = prgName.EndsWith("VSHOST.EXE");
        }
        return inIDE;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM