Created
August 1, 2013 07:50
-
-
Save tugberkugurlu/6129289 to your computer and use it in GitHub Desktop.
How to check if an assembly was built using Debug or Release configuration (ref: http://stackoverflow.com/questions/2186613/how-to-check-if-an-assembly-was-built-using-debug-or-release-configuration)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
namespace CheckIfDebugOrRelease | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Assembly assembly = Assembly.LoadFile(@"C:\Dev\Prv\Samples\CheckIfDebugOrRelease\CheckIfDebugOrRelease\lib\CheckIfDebugOrRelease.exe"); | |
IEnumerable<Attribute> customAttributes = assembly.GetCustomAttributes(); | |
IEnumerable<Attribute> debuggableAttributes = from attribute in customAttributes | |
let debuggableAttribute = attribute as DebuggableAttribute | |
where debuggableAttribute != null && debuggableAttribute.IsJITTrackingEnabled | |
select attribute; | |
if (debuggableAttributes.Any()) | |
{ | |
Console.ForegroundColor = ConsoleColor.Red; | |
Console.WriteLine("'{0}' has been compiled in Debug mode!", assembly.FullName); | |
} | |
else | |
{ | |
Console.ForegroundColor = ConsoleColor.Cyan; | |
Console.WriteLine("'{0}' has not been compiled in Debug mode!", assembly.FullName); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment