473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Tell Debug and Release files apart

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
6 2325
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: nospam | last post by:
All the documentation says that leaving an ASP.NET application in debug mode has a big performance hit. I can't detect any difference between debug and non-debug modes. Am I missing something or is...
9
by: dee | last post by:
Hi I'm about to upload my site and I have switched to release version. Is that enough or do I still need to disable <compilation defaultLanguage="vb" debug="true" /> the debug="true" in the .pdb...
19
by: Alan Silver | last post by:
Hello, I have been developing ASP.NET with a text editor so far (better way to learn initially), and have now been trying Visual Web Developer. I want to create a project for an existing site...
6
by: Brian Henry | last post by:
I am trying to tell if my site is running as a debug build or not in asp.net 1.1 you could say #IF DEBUG DO SOMETHING HERE #ENDIF but in ASP.NET 2.0 it seems not to work anymore... why...
3
by: Bob | last post by:
I Debug build my (WinForms) assemblies and then deploy them (simple copy to client) without the .pdb files. This works fine, but I like to know: - Without the .pdb files, will the .dll's act...
10
by: Joe Befumo | last post by:
When I tried debugging for the first time, I pop-up asked me if I wanted to set the project to enable debugging. Now I'm ready to release and can't find anyplace to set the build to 'release'. A...
4
by: nmrcarl | last post by:
I'm trying to upgrade a large project from VS 6.0 to VS 2005. After fixing a lot of things that changed (mostly sloppy coding in the original project that VS2005 didn't allow), I got the release...
6
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++...
3
by: TBass | last post by:
Hello, Is there a way to get Visual Studio 2003 look to one directory for debug version dlls when set to DEBUG and then to another directory where I store the release version of a dll when set...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.