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

Viewed 4663

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

2 Answers
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;
    }
}
Related