For example, to verify whether the current application was compiled in release or debug mode:
- Inspect the Attributes collection of the Assembly object specified by a dll path.
- Find the Attribute of type DebuggableAttribute.
- Check that Attribute's IsJITTrackingEnabled property.
Here is a link to the code.
I used it to display the compile mode in an About screen:

