Have a look this one, I just wrote:
Accurate way to tell if an assembly is compiled in debug or release mode in c#[
^]
public static bool IsInDebugMode(string FileName)
{
var assembly = System.Reflection.Assembly.LoadFile(FileName);
var attributes = assembly.GetCustomAttributes(typeof(System.Diagnostics.DebuggableAttribute), false);
if (attributes.Length > 0)
{
var debuggable = attributes[0] as System.Diagnostics.DebuggableAttribute;
if (debuggable != null)
return (debuggable.DebuggingFlags & System.Diagnostics.DebuggableAttribute.DebuggingModes.Default) == System.Diagnostics.DebuggableAttribute.DebuggingModes.Default;
else
return false;
}
else
return false;
}