473,404 Members | 2,137 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,404 software developers and data experts.

Determining Debug vs Release Mode at compile time

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.

--
-wiz
Mar 21 '07 #1
4 3696
WizyDig <Wi*****@discussions.microsoft.comwrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 21 '07 #2
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.
--
-wiz
"Jon Skeet [C# MVP]" wrote:
WizyDig <Wi*****@discussions.microsoft.comwrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 21 '07 #3
WizyDig <Wi*****@discussions.microsoft.comwrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 21 '07 #4
Hi wiz,

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

Christof

"WizyDig" <Wi*****@discussions.microsoft.comschrieb im Newsbeitrag
news:6F**********************************@microsof t.com...
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.

--
-wiz

Mar 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chad Slagle via DotNetMonster.com | last post by:
in "c:\Root.Aspects.Exceptions\example.vb(20)" I receive an: error BC30456 'Insrumentation' is not a member of 'Aspects. In the Solution the following projects exist: Root.Aspects.Exceptions...
4
by: Claire | last post by:
How do I determine whether Im running in debug or release mode from code please. thanks Claire
5
by: David Krmpotic | last post by:
it's me again.. with quite interesting discovery :) I was tracing an error for 3 hours instead of 3 minutes because of this surprise. Recently I'm compiling this project in RELEASE with Debug...
7
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed from the code. I tried to implement this thing by...
3
by: Haldun ALIML | last post by:
Suppose that you have below property in some class, #if DEBUG public string DebugInfo { get { return "INDEX : " + _name + "\n" + "Index Owner : " + _owner.Name + "\n" + "Index Column Count:...
6
by: Boni | last post by:
Dear all, I have following problem. I created a static libruary (mylib.lib). I compiled it with Multithreaded DLL runtime in release mode. Now I want to give out this library. But users who...
5
by: sujeet | last post by:
Dear friends, I'm facing a strange problem... My Application is in Debug mode, and the third party static library i'm using is in release mode. When i compile and try to link my...
0
by: =?Utf-8?B?SmVmLnB0Yw==?= | last post by:
Hi, I am currently facing exactly the same issue with Visual Studio 2005. Did you find a way to solve this problem ? "AntonioSACE" wrote:
3
by: =?Utf-8?B?bG10dGFn?= | last post by:
We have developed a number of different applications (ASP.NET web site, Windows services, DLLs, Windows forms, etc.) in C# 2.0. We have developed and unit tested all these applications/components...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.