簡體   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