如何判断程序是在调试状态下运行?或者能判断VS的IDE在运行也行。

解决方案 »

  1.   

    不知道怎么判断是否处于调试状态,只知道怎么判断当前程序的Build版本是Debug还是Release
    //判断程序是否含有调试信息
    string buildtype;
    try
    {
    bool found = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(DebuggableAttribute), false).Length > 0;
    buildType = found ? "Debug" : "Release";
    }
    catch
    {
    buildType = "<error>";
    }
      

  2.   

    #If DEBUG Then     '调试状态下运行
            Else#End If