Are your assemblies from a release or debug build?

Ever wondered if the assemblies your developers gives you to install on a production server are from a release build? You can make a little C# console application to check this.

Copy the following text into a new file named “IsModeDebug.cs”

using System;
using System.Reflection;
using System.Diagnostics;
namespace IsModeDebug
public class IsDbg
// Errorlevels, for batch reasons:
// 0 = Non-Debug Assembly
// 1 = Debug Assembly
// 2 = No assembly name passed on command line
// 4 = Exception thrown
public static int Main(String[] args)
if (args.Length != 1)
Console.WriteLine("\nError: Not enough command line options specified.");
Console.WriteLine("Usage: \"IsModDebug <path to assembly>\"");
return (2);
Assembly asm = Assembly.LoadFile(args[0], null);
DebuggableAttribute objDebuggable =(DebuggableAttribute)DebuggableAttribute.GetCustomAttribute(asm, typeof(DebuggableAttribute));
if (objDebuggable == null)
Console.WriteLine("Non-Debug Assembly");
return (0);
if (objDebuggable.IsJITOptimizerDisabled || objDebuggable.IsJITTrackingEnabled)
Console.WriteLine("Debug Assembly");
Console.WriteLine("JITOptimizerDisabled = {0}", objDebuggable.IsJITOptimizerDisabled);
Console.WriteLine("IsJITTrackingEnabled = {0}", objDebuggable.IsJITTrackingEnabled);
catch (Exception e)
Console.WriteLine("Exception: {0}!!!", e.Message);
return (4);
return (1); // Debug Module Found

Compile into a (release) executable with the following syntax (modify the paths to your own environment).

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /debug- /optimize+ /out:C:\Temp\\IsModeDebug.exe /target:exe C:\Temp\IsModeDebug.cs

Usage: “IsModeDebug.exe path_to_assembly”

Hope this helps…Credits go to James for the code.

Leave a Reply

Your email address will not be published. Required fields are marked *