473,789 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implement Interface in debug build only

I have a class which implements several interfaces. One of them I
would like to have implemented only if it is a debug build. Is there
a way to do this?

Thanks.

Aug 30 '07 #1
8 1804
Hello ramhog,

and what the problem? just use #if DEBUG preprocessor directive for this

but u cant miss implementing some interfaces, u need provide either debug
implementation or the standart one

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
rI have a class which implements several interfaces. One of them I
rwould like to have implemented only if it is a debug build. Is there
ra way to do this?
r>
rThanks.
r>
Aug 30 '07 #2
The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if DEBUG...#endif
around the methods, then a release build will have errors because the
interface isn't fully implemented.

public class MyBigTestClass : IReleaseMethods , ITestMethods
{
....
}

In this example, I want to only have the ITestMethods implemented in a
debug build.

I hope I am making sense.

Thank you for your help.

On Aug 30, 10:05 am, Michael Nemtsev <nemt...@msn.co mwrote:
Hello ramhog,

and what the problem? just use #if DEBUG preprocessor directive for this

but u cant miss implementing some interfaces, u need provide either debug
implementation or the standart one

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

rI have a class which implements several interfaces. One of them I
rwould like to have implemented only if it is a debug build. Is there
ra way to do this?
r>
rThanks.
r>

Aug 30 '07 #3
Hello ramhog,

Then I suppose u need to have the 2 classes, and wrapping one with #if debug
and another with #if RELEASE

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
rThe problem with this is that if I only want to have the interface
rimplmented during a debug build. If I just put the #if
rDEBUG...#endif around the methods, then a release build will have
rerrors because the interface isn't fully implemented.
r>
rpublic class MyBigTestClass : IReleaseMethods , ITestMethods
r{
r...
r}
rIn this example, I want to only have the ITestMethods implemented in
ra debug build.
r>
rI hope I am making sense.
r>
rThank you for your help.
r>
rOn Aug 30, 10:05 am, Michael Nemtsev <nemt...@msn.co mwrote:
r>
>Hello ramhog,

and what the problem? just use #if DEBUG preprocessor directive for
this

but u cant miss implementing some interfaces, u need provide either
debug implementation or the standart one

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo

rI have a class which implements several interfaces. One of them I
rwould like to have implemented only if it is a debug build. Is
there
ra way to do this?
r>
rThanks.
r>

Aug 30 '07 #4
Hi,
"ramhog" <ka*********@ng c.comwrote in message
news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if DEBUG...#endif
around the methods, then a release build will have errors because the
interface isn't fully implemented.
You have to do the same in the declaration:
class AddEditAgencySe ssionInfo
#if DEBUG
: IDisposable
#endif
Aug 30 '07 #5
On Aug 30, 10:19 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
Hi,

"ramhog" <kalvin.t...@ng c.comwrote in message

news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if DEBUG...#endif
around the methods, then a release build will have errors because the
interface isn't fully implemented.

You have to do the same in the declaration:
class AddEditAgencySe ssionInfo
#if DEBUG
: IDisposable
#endif
Thanks for everyones help.

This gives me an error:
class MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
{...}

I have tried different variantions of this with the same problem, such
as:
class MyTestClass : IReleaseMethods , #if DEBUG IDebugMethods #endif
class MyTestClass #if DEBUG : IReleaseMethods , IDebugMethods #endif
Aug 30 '07 #6
Hello ramhog,

Just check your code, everything works fine

u can use the following code to check it

public interface IMyInterface
{
void MethodOne();
void MethodTwo();
}

class Program
#if DEBUG
: IMyInterface
#endif

{
static void Main(string[] args)
{
}
#if DEBUG

#region IMyInterface Members

public void MethodOne()
{
throw new NotImplementedE xception();
}

public void MethodTwo()
{
throw new NotImplementedE xception();
}

#endregion

#endif

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
rOn Aug 30, 10:19 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
rlaceupsolution s.comwrote:
r>
>Hi,

"ramhog" <kalvin.t...@ng c.comwrote in message

news:11******* *************** @d55g2000hsg.go oglegroups.com. ..
>>The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if
DEBUG...#endi f around the methods, then a release build will have
errors because the interface isn't fully implemented.
You have to do the same in the declaration:
class AddEditAgencySe ssionInfo
#if DEBUG
: IDisposable
#endif
rThanks for everyones help.
r>
rThis gives me an error:
rclass MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
r{...}
rI have tried different variantions of this with the same problem,
rsuch
ras:
rclass MyTestClass : IReleaseMethods , #if DEBUG IDebugMethods #endif
rclass MyTestClass #if DEBUG : IReleaseMethods , IDebugMethods #endif
Aug 30 '07 #7
ramhog <ka*********@ng c.comwrote:
Thanks for everyones help.

This gives me an error:
class MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
{...}
Yes, it would.
I have tried different variantions of this with the same problem, such
as:
class MyTestClass : IReleaseMethods , #if DEBUG IDebugMethods #endif
class MyTestClass #if DEBUG : IReleaseMethods , IDebugMethods #endif
You didn't try the code as posted though, I suspect.

Pre-processor directives need to be on lines on their own. Use exactly
the code Ignacio posted instead.

To be honest though, I'd try to avoid having this kind of thing in the
first place. It sounds like a recipe for problems.

--
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
Aug 30 '07 #8
On Aug 30, 1:04 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
ramhog <kalvin.t...@ng c.comwrote:
Thanks for everyones help.
This gives me an error:
class MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
{...}

Yes, it would.
I have tried different variantions of this with the same problem, such
as:
class MyTestClass : IReleaseMethods , #if DEBUG IDebugMethods #endif
class MyTestClass #if DEBUG : IReleaseMethods , IDebugMethods #endif

You didn't try the code as posted though, I suspect.

Pre-processor directives need to be on lines on their own. Use exactly
the code Ignacio posted instead.

To be honest though, I'd try to avoid having this kind of thing in the
first place. It sounds like a recipe for problems.

--
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
Thank you very much all of you for your help. I didn't realize the
directive had to be on it's own line, that worked good.

class MyTestClass : IReleaseMethods
#if DEBUG
, ITestMethods
#endif

Aug 30 '07 #9

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

Similar topics

0
2632
by: Joe Hershman | last post by:
all, not sure what the best place to post this one, hopefully someone can help because this is a real show stopper. i am getting the error shown below when i try to build a deployment project. all the projects build fine, but when vs.net starts to create the msi the error occurs. i am seeing this same (the file sometimes differs) error on two different machines so i don't think it is related to the computer. i have uninstalled...
0
1519
by: Adam Tomjack | last post by:
I'm trying to embed Python 2.3.5 into a C++ application on Windows XP. When I build my app with debug symbols and link to a debug build of Python, then my program seems to crash most (but not all) of the time. Sometimes it crashes on startup, and sometimes at exit, sometimes not at all. I haven't seen it crash with non-debug builds of my app and Python. The release build runs my Python test code just fine. When the debug build doesn't...
175
8910
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
6
1633
by: Alpha | last post by:
Hi, I'm fixing a bug in an application and need to step thru the appl to find where it's occuring. The main project includs 33 other projects each having a .resx file in it. When I step through it would give me message that it can't show me codes because only assembly codes are available. Is there any good article on how to debug something like this? Also, I've only being working with C#.net for 3 months and am still not very familiar...
7
1591
by: Tom | last post by:
How can I make code not execute for a debug build, but do execute for a production build? I have code which prompts for an account and password when the program starts up. It is a pain to have to answer that when I repeatly run the program during debugging, but it is desired by my client. Presently I just comment it out when I am debugging, but I was wondering if there was a more automatic way? Some type of conditional compilation...
7
15712
by: moondaddy | last post by:
If I'm in a class that inherits an interface, is there a shortcut key that will write the implementation of the interface into the class? I remember seeing something like this in vb.net. Thanks. -- moondaddy@nospam.nospam
0
2837
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass magic, I wrote the following module. It is mainly useful as a light weight tool to help programmers catch mistakes at definition time (e.g., forgetting to implement a method required by the given interface). This is handy when unit tests or...
4
4473
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am developing website application in asp.net , visual C# and atl com. I am using atl com component in visual C# application. One of the function of com component interface returns IStream interface. I want to read data from that IStream interface. I am new to visual c#. I have written some code. But, it is returning whole data. It is returning some null characters.
7
9373
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should display the Windows form. The form is being displayed but the command only returns when the form is closed. I want the command line to return immediately, leaving the form displayed.
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10412
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
10142
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
9986
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
7529
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
6769
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
5422
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...
1
4093
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
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.