Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>IMHO, The above application is really misleading; it only looks for the IsJITTrackingEnabled which is completely independent of whether or not the code is compiled for optimization and JIT Optimization.</p> <p>The DebuggableAttribute is present if you compile in Release mode and choose DebugOutput to anything other than "none".</p> <p>You also need to define <em>exactly</em> what is meant by "Debug" vs. "Release"...</p> <p>Do you mean that the app is configured with code optimization? Do you mean that you can attach the VS/JIT Debugger to it? Do you mean that it generates DebugOutput? Do you mean that it defines the DEBUG constant? Remember that you can conditionally compile Methods with the System.Diagnostics.Conditional() attribute.</p> <p>IMHO, when someone asks whether or not an assembly is "Debug" or "Release", they really mean if the code is optimized...</p> <p>Sooo, do you want to do this manually or programmatically?</p> <p><strong>Manually</strong>: You need to view the value of the DebuggableAttribute bitmask for the assembly's metadata. Here's how to do it:</p> <ol> <li>Open the assembly in ILDASM</li> <li>Open the Manifest</li> <li>Look at the DebuggableAttribute bitmask. If the DebuggableAttribute is not present, it is definitely an Optimized assembly.</li> <li>If it is present, look at the 4th byte - if it is a '0' it is JIT Optimized - anything else, it is not:</li> </ol> <blockquote> <p>// Metadata version: v4.0.30319 .... // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 <strong>00</strong> 00 00 00 00 )</p> </blockquote> <p><strong>Programmatically</strong>: assuming that you want to know programmatically if the code is JITOptimized, here is the correct implementation:</p> <pre><code>object[] attribs = ReflectedAssembly.GetCustomAttributes(typeof(DebuggableAttribute), false); // If the 'DebuggableAttribute' is not found then it is definitely an OPTIMIZED build if (attribs.Length &gt; 0) { // Just because the 'DebuggableAttribute' is found doesn't necessarily mean // it's a DEBUG build; we have to check the JIT Optimization flag // i.e. it could have the "generate PDB" checked but have JIT Optimization enabled DebuggableAttribute debuggableAttribute = attribs[0] as DebuggableAttribute; if (debuggableAttribute != null) { HasDebuggableAttribute = true; IsJITOptimized = !debuggableAttribute.IsJITOptimizerDisabled; BuildType = debuggableAttribute.IsJITOptimizerDisabled ? "Debug" : "Release"; // check for Debug Output "full" or "pdb-only" DebugOutput = (debuggableAttribute.DebuggingFlags &amp; DebuggableAttribute.DebuggingModes.Default) != DebuggableAttribute.DebuggingModes.None ? "Full" : "pdb-only"; } } else { IsJITOptimized = true; BuildType = "Release"; } </code></pre> <p>I've provided this implementation on my blog at:</p> <p><strong><a href="http://dave-black.blogspot.com/2011/12/how-to-tell-if-assembly-is-debug-or.html" rel="noreferrer">How to Tell if an Assembly is Debug or Release</a></strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload