473,699 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking DEBUG constant from different assembly?

Say I have this setup:

[A.DLL]
public static void SomeMethod()
{
#if DEBUG
....
#endif
}

[B.EXE]
A.Class1.SomeMe thod();

In A.DLL's project property build tab, DEBUG constant is turned off
while it is one for B.EXE. This isn't transient however. The code
doesn't execute. A.DLL has to have the DEBUG constant turned on, which
will always run the code. I want the caller to determine if the code
should run or not. Any suggestions?

Thanks,
Brett

Apr 25 '06 #1
4 2212
Brett Romero <ac*****@cygen. com> wrote:
Say I have this setup:

[A.DLL]
public static void SomeMethod()
{
#if DEBUG
....
#endif
}

[B.EXE]
A.Class1.SomeMe thod();

In A.DLL's project property build tab, DEBUG constant is turned off
while it is one for B.EXE. This isn't transient however. The code
doesn't execute. A.DLL has to have the DEBUG constant turned on, which
will always run the code. I want the caller to determine if the code
should run or not. Any suggestions?


I don't believe there's a way of doing this with pre-processor symbols.
You'd need to use a normal variable of some description.

I feel your pain though - it means that if you want to let people debug
through your code etc, you need to publish two versions of libraries -
a debug version and a release version :(

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 25 '06 #2
I basically have to create some parameter flag than to pass into each
of these methods? Maybe it isn't so bad. I can create a static bool
var in B.EXE's program.cs (or what ever the startup file is) and just
reference it from there. I could also probably use the app.config to
get the flag value. That sound work able?

Thanks,
Brett

Apr 25 '06 #3
Brett Romero <ac*****@cygen. com> wrote:
I basically have to create some parameter flag than to pass into each
of these methods? Maybe it isn't so bad. I can create a static bool
var in B.EXE's program.cs (or what ever the startup file is) and just
reference it from there. I could also probably use the app.config to
get the flag value. That sound work able?


Well, I'd have a property in A.dll which can be set by B.exe - it's a
pain to have to pass it on every method call. You almost certainly
won't be able to reference a property in B.exe from A.dll - normally an
executable references a class library, not the other way round.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 25 '06 #4
That's what I'm referring to but in B.exe I want a simple way to turn
that property on/off. Basically I want the method contents to execute
if the property is true and not if false. It's a debug switch more or
less.

I guess what I'm asking is, how do I set something in the B.exe
app.config file, which B.exe can read and set the value of a static
variable that is used across B.exe? I'll then pass that static var
into the constructor of the A.DLL object, which is the condition to
execute the method code or not. Now I have a switch that can be turned
on/off from the app.config file.

Thanks,
Brett

Apr 25 '06 #5

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

Similar topics

3
8238
by: William Ryan | last post by:
This is going to be really stupid...but I often define method/properties with an Attribute of Debug. When I compile for build, they cease to exist. This is cool. However, is there a constant to the inverse? What I want to do is if I have a Debug Build, I want to skip all sorts of log-on stuff and the like. Right now, I'm manually setting a property in the build properties, but I was wondering if there is a more elegant way to do it..ie...
1
570
by: Carl Mercier | last post by:
Hi! I have 2 different applications/assembly. The first one creates an object and serializes it to a textfile on disk. The second one has the the exact same class (copied/pasted). It reads the file that is on disk and attempts to deserialize it and create a new object. The process works fine if I serialize/deserialize in the first
1
1614
by: Susan Bricker | last post by:
Hi. I have a form with a label (lblNavigate). The text (caption) is supposed to state, either, "New Record" or "xxx of yyy" (where xxx = current record number and yyy = total number of records). I set me!lblNavigate.caption in the Form_Current( ) routine. If I don't trace the routine, the text shows ("1 of 1"). There are, actually, 2 records in the recordset. If I trace the routine (debug mode) the text gets populated properly and it...
0
1517
by: Zsolt Domokos | last post by:
I serialised data in an assembly and I want to deserialize in different assembly but I get an exception: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll Additional information: File or assembly name ASSEMBLY1, or one of its dependencies, was not found. How can I deserialize it?
2
10339
by: Carl Mercier | last post by:
Hi! I have 2 different applications/assembly. The first one creates an object and serializes it to a textfile on disk. The second one has the the exact same class (copied/pasted). It reads the file that is on disk and attempts to deserialize it and create a new object. The process works fine if I serialize/deserialize in the first
1
1354
by: Tim Bücker | last post by:
Hello. Are there any resources out there (because I couldn´t find any) concerning the usage of assemblies with different features in each version? In other words: I´ve got one assembly A that is using assembly B - B exists in different versions. Now I want to make it possible for A to ask B what features it supports or what data it can give to A.
7
4798
by: =?Utf-8?B?SmltIFdhbHNo?= | last post by:
I'm new to working with mixed assemblies. All of my previous experience has been with VC++/MFC in native, unmanaged applications. When I create a mixed assembly in which one or more of the files compiles with /clr the instructions say that I need to change the switch for Debug information format from Program Database for Edit & Continue to disabled. At runtime I find that I am not able to set breakpoints in the managed code, nor trace...
0
1402
by: Dmitrii | last post by:
My C# project has 4-configuration: Debug, Release, DebugPlus, and ReleasePlus. In each of these configurations the C# program should consume (be "linked" to) a different Assembly.dll build created by a C++/CLI multiple configuration project:: Debug, Release, DebugPlus, and ReleasePlus Assembly.dll, respectively. So far I could not find a way to do this.
1
2406
by: somequestion | last post by:
i'd like to use delegate but it is not in same assembly. how should i do to solve this... source code is like below... using B; namespace A { class A { funcA()
0
8612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.