姿夏的海角
为钱做事,容易累;为理想做事,能够耐风寒;为兴趣做事,则永不倦怠

1.第一种 (常用)

#if DEBUG

   //debugger 环境

#else
  //release 环境
#endif

  

2. 第二种

private bool IsDebug()
        {
            Assembly assembly = Assembly.GetAssembly(GetType());
            bool debug = false;
            foreach (var attribute in assembly.GetCustomAttributes(false))
            {
                if (attribute.GetType() == typeof(System.Diagnostics.DebuggableAttribute))
                {
                    if (((System.Diagnostics.DebuggableAttribute)attribute)
                        .IsJITTrackingEnabled)
                    {
                        debug = true;
                        break;
                    }
                }
            }
            return debug;
        }

  

posted on 2019-04-22 09:17  姿夏的海角  阅读(1480)  评论(0编辑  收藏  举报