How to determine if a .NET Assembly was compiled in Debug Mode
A colleague asked this question in an email and as often happens I didn't know the answer. However Mark Rees did, and as I couldn't find the answer on the web just thought I would post it here as I thought it was rather a gem:
The best way to do this is to load the assembly in code and grab the System.Diagnostics.DebbugableAttribute attribute from the assembly custom attributes collection and check to see if the "IsJITTrackingEnabled" property is true.
- If it is true then the assembly was compiled in debug mode; if it's false then it wasn't.
- If the attribute is not present then the assembly was also not compiled in debug mode.
Now I know. Thanks Mark!
Comments
- Anonymous
April 05, 2006
Without code, I would think that you could pop open ILDASM and look at what DebuggerAttribute flags are set.