Determining Debug vs Release Mode at compile time

G

Guest

We have been trying to detirmine if a dll is compiled in Release or Debug
mode after it is compiled. I found serveral methods using reflection but
when test they all seemed to fail. Is there a way to detirmine if a compiled
assembly was compiled in Debug or release mode. We would like to add this to
our Automated build process.
 
J

Jon Skeet [C# MVP]

WizyDig said:
We have been trying to detirmine if a dll is compiled in Release or Debug
mode after it is compiled. I found serveral methods using reflection but
when test they all seemed to fail. Is there a way to detirmine if a compiled
assembly was compiled in Debug or release mode. We would like to add this to
our Automated build process.

You could have a member (or even a whole type!) which is only declared
in debug mode:

#if DEBUG
public static boolean ThisWasCompiledInDebugMode;
#endif
 
G

Guest

We need to be able to determine this with out running the code. I'm familiar
with the #if DEBUG it only works at run time.
 
J

Jon Skeet [C# MVP]

WizyDig said:
We need to be able to determine this with out running the code. I'm familiar
with the #if DEBUG it only works at run time.

Given that the member will be present or not, you can open the assembly
in something like reflector and check for its presence or absence. No
need to run any code in the assembly.
 
C

Christof Nordiek

Hi wiz,

you could set the AssemblyConfiguration attribute dependend from the debug
mode.
This also can be read with reflection

Christof
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top