By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,081 Members | 861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,081 IT Pros & Developers. It's quick & easy.

Tell Debug and Release files apart

P: n/a
Is there a way to tell if an assembly was compiled on Debug or Release mode?
I tried viewing the file usin Ildasm but did't notice any special comment
line or something that would tell me if it was Debugged or Released.

Thanks.
Dec 1 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
For assemblies that you control, you could put a custom attribute (that
you define) on the assembly inside a conditional compilation block:

#if DEBUG
[assembly: CompilationMode("Debug")]
#else
[assembly: CompilationMode("Release")]
#endif

Then you could use reflection to load the assembly and get a list of
its attributes, or just look at the assembly manifest with ILDASM.

Jesse

Dec 1 '05 #2

P: n/a
Say that your coworker compiled a dll for you and sent it over to you via
email. The file does not have any attributes, comment or anything else put
in by your coworker to tell you if the file was created as debugged or
released.

When you tried to contact him to ask him if the dll was compile on Debug or
Release mode you are not able to reach him. It is very important that you
find out how the file was compiled otherwise the world could cease to exist.
What do you do?

<jm*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
For assemblies that you control, you could put a custom attribute (that
you define) on the assembly inside a conditional compilation block:

#if DEBUG
[assembly: CompilationMode("Debug")]
#else
[assembly: CompilationMode("Release")]
#endif

Then you could use reflection to load the assembly and get a list of
its attributes, or just look at the assembly manifest with ILDASM.

Jesse

Dec 1 '05 #3

P: n/a
Some brief experimentation suggests that the compiler automatically
adds a System.Diagnostics.DebuggableAttribute to the assembly when it's
compiled in debug mode (csc /debug+).

Also, debug mode usually means optimizations are off, and you can spot
an unoptimized method because it'll be full of "nop" instructions.

Jesse

Dec 1 '05 #4

P: n/a
Thanks, any chance you could tell me were can I see this
"System.Diagnostics.DebuggableAttribute" attribute?

Is this something you can see using Ildasm? I open a Debugged file using
Ildasm and I just can't find this Attribute, I must be missing something
really obvious.

Thanks.
<jm*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Some brief experimentation suggests that the compiler automatically
adds a System.Diagnostics.DebuggableAttribute to the assembly when it's
compiled in debug mode (csc /debug+).

Also, debug mode usually means optimizations are off, and you can spot
an unoptimized method because it'll be full of "nop" instructions.

Jesse

Dec 1 '05 #5

P: n/a
Hi Rene,

You can use the code below from within a running assembly (VB.NET, translate
it to C#). For an external assembly, use objAssembly =
System.Reflection.Assembly.LoadXXX(...)

Dim objAssembly As System.Reflection.Assembly

objAssembly = System.Reflection.Assembly.GetExecutingAssembly()

If objAssembly.GetCustomAttributes(GetType(Debuggable Attribute),
True).GetLength(0) > 0 Then
MessageBox.Show("Debug")
Else
MessageBox.Show("Release")
End If

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Rene" <no****@nospam.com> escribió en el mensaje
news:uJ**************@TK2MSFTNGP09.phx.gbl...
Thanks, any chance you could tell me were can I see this
"System.Diagnostics.DebuggableAttribute" attribute?

Is this something you can see using Ildasm? I open a Debugged file using
Ildasm and I just can't find this Attribute, I must be missing something
really obvious.

Thanks.
<jm*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Some brief experimentation suggests that the compiler automatically
adds a System.Diagnostics.DebuggableAttribute to the assembly when it's
compiled in debug mode (csc /debug+).

Also, debug mode usually means optimizations are off, and you can spot
an unoptimized method because it'll be full of "nop" instructions.

Jesse


Dec 1 '05 #6

P: n/a
Is there a way to tell if an assembly was compiled on Debug or Release

mode?

Check out Jeff Key's IsDebug at http://www.sliver.com/dotnet/IsDebug/
Dec 1 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.