繁体   English   中英

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

[英]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;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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