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; } } } //csharp/5912