Determine if a .NET Assembly is Release or Debug

We recently got a bug report where a tester got a Debug.Assert failure in what I thought was a Release mode build. I went over to her machine, but found I couldn't tell from the binaries if it was a Release or a Debug build. ILDASM is no help, as Debug and Release are just build modes, and don't leave markers in the assemblies.

To differentiate between Release and Debug builds, I added the following to my AssemblyInfo.cs

// Compile a Debug or Release flag into the assembly.

#if DEBUG

[assembly: AssemblyDescription("Debug")]

#else

[assembly: AssemblyDescription("Release")]

#endif

 

This places Debug or Release in the file's metadata, where it can be seen under Properties | Version | Comments.

Published 16 June 2004 03:30 PM by Ted_Graham

Comments

# Scott Galloway said on 16 June, 2004 05:56 PM
Excellent tip...thanks!
# Michael Collins said on 16 June, 2004 06:10 PM
I have typically used the AssemblyConfigurationAttribute attribute instead to indicate the Debug and Release builds. I think it fits a little better than using the assembly description.
# Bill McCarthy said on 16 June, 2004 09:28 PM
Hi Ted,

Actually you can tell from ILDASM if an assembly is debug or release build.

See my blog, http://msmvps.com/bill/archive/2004/06/17/8339.aspx

for a non intrusive way of telling if an assembly is debug or release
# TrackBack said on 17 June, 2004 05:38 AM
# TrackBack said on 17 June, 2004 06:32 AM
Ted Graham has a great tip on how to determine whether a .NET assembly is a Release or Debug build. Basically you just add the following code to AssemblyInfo.cs: // Compile a Debug or Release flag into the assembly. #if...
# Patrick Steele said on 17 June, 2004 09:01 AM
Becareful with AssemblyDescription attribute and COM interop.

http://weblogs.asp.net/psteele/archive/2004/06/17/158122.aspx
# TrackBack said on 17 April, 2005 07:06 AM
^_~,pretty good!

Leave a Comment

(required) 
(required) 
(optional)
(required)