odiseh
odiseh

Reputation: 26517

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

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

Upvotes: 28

Views: 4939

Answers (2)

Webleeuw
Webleeuw

Reputation: 7282

if (System.Diagnostics.Debugger.IsAttached) {
    // You are debugging
}

Upvotes: 35

mkus
mkus

Reputation: 3487

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;
    }
}

Upvotes: 7

Related Questions