473,488 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to use #If (Conditional Compilation) for framework versions?

Hi,

Is there a way to include an #If ... directive in my code to enable
conditional compilation based on the framework version?

The idea is to be able to compile the "same" code for both the 1.0 framework
and the 1.1 framework, something like

#If "Framework 1.0 etected" then
DO NOT USE SOME FUNCTION (as it uses some 1.1 only properties of certain
classes)
else
BUILD FOR 1.1

p.s.
To be more specific it's the Fields property of the MailMessage class that
gives me headakes - the Fields property does not exist in the 1.0 framework.
Thanks!

Zarko
Jul 21 '05 #1
4 1942

ms-
help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemDiagno
sticsConditionalAttributeClassTopic.htm

public sealed class ConditionalAttribute : Attribute

hope this will help
-----Original Message-----
Hi,

Is there a way to include an #If ... directive in my code to enableconditional compilation based on the framework version?

The idea is to be able to compile the "same" code for both the 1.0 frameworkand the 1.1 framework, something like

#If "Framework 1.0 etected" then
DO NOT USE SOME FUNCTION (as it uses some 1.1 only properties of certainclasses)
else
BUILD FOR 1.1

p.s.
To be more specific it's the Fields property of the MailMessage class thatgives me headakes - the Fields property does not exist in the 1.0 framework.

Thanks!

Zarko
.

Jul 21 '05 #2

ms-
help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemDiagno
sticsConditionalAttributeClassTopic.htm

public sealed class ConditionalAttribute : Attribute

hope this will help
-----Original Message-----
Hi,

Is there a way to include an #If ... directive in my code to enableconditional compilation based on the framework version?

The idea is to be able to compile the "same" code for both the 1.0 frameworkand the 1.1 framework, something like

#If "Framework 1.0 etected" then
DO NOT USE SOME FUNCTION (as it uses some 1.1 only properties of certainclasses)
else
BUILD FOR 1.1

p.s.
To be more specific it's the Fields property of the MailMessage class thatgives me headakes - the Fields property does not exist in the 1.0 framework.

Thanks!

Zarko
.

Jul 21 '05 #3
Hi,

I would need a sample code .. of course...

p.s.
I am aware of the System.Diagnostics.ConditionalAttribute class .. but am
not sure how to test for the framework version.

Zarko

<an*******@discussions.microsoft.com> wrote in message
news:5e****************************@phx.gbl...

ms-
help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemDiagno
sticsConditionalAttributeClassTopic.htm

public sealed class ConditionalAttribute : Attribute

hope this will help
-----Original Message-----
Hi,

Is there a way to include an #If ... directive in my code

to enable
conditional compilation based on the framework version?

The idea is to be able to compile the "same" code for

both the 1.0 framework
and the 1.1 framework, something like

#If "Framework 1.0 etected" then
DO NOT USE SOME FUNCTION (as it uses some 1.1 only

properties of certain
classes)
else
BUILD FOR 1.1

p.s.
To be more specific it's the Fields property of the

MailMessage class that
gives me headakes - the Fields property does not exist in

the 1.0 framework.


Thanks!

Zarko
.

Jul 21 '05 #4
Hi,

I would need a sample code .. of course...

p.s.
I am aware of the System.Diagnostics.ConditionalAttribute class .. but am
not sure how to test for the framework version.

Zarko

<an*******@discussions.microsoft.com> wrote in message
news:5e****************************@phx.gbl...

ms-
help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemDiagno
sticsConditionalAttributeClassTopic.htm

public sealed class ConditionalAttribute : Attribute

hope this will help
-----Original Message-----
Hi,

Is there a way to include an #If ... directive in my code

to enable
conditional compilation based on the framework version?

The idea is to be able to compile the "same" code for

both the 1.0 framework
and the 1.1 framework, something like

#If "Framework 1.0 etected" then
DO NOT USE SOME FUNCTION (as it uses some 1.1 only

properties of certain
classes)
else
BUILD FOR 1.1

p.s.
To be more specific it's the Fields property of the

MailMessage class that
gives me headakes - the Fields property does not exist in

the 1.0 framework.


Thanks!

Zarko
.

Jul 21 '05 #5

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

Similar topics

3
343
by: ME | last post by:
I would like to write a .NET Compact Framework App Simultaneously with a standard .NET App using Conditional Compilation. However I have run into a bit of, what I believe, a misunderstanding. How...
2
2568
by: FireStarter | last post by:
Guys, in the code that follows, why does the method F() still compile, even if DBG is undefined? Inside method G(), the code inside <#if DBG> does not compile (notice that I can write whatever I...
2
318
by: Zarko Gajic | last post by:
Hi, Is there a way to include an #If ... directive in my code to enable conditional compilation based on the framework version? The idea is to be able to compile the "same" code for both the...
28
2605
by: richardlang | last post by:
Anyone out there ever come across a preprocessor macro that compares an argument value against the predefined __DATE__ macro in order to control conditional compilation based on date. Something...
4
2789
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
1
2273
by: Marek | last post by:
I use VS2005 with framework 2.0 and I just found a behavior I consider odd. Here is the code that illustrates th eproblem: public static void MethodA() { MethodB() } #if DEBUG
6
2828
by: maxwell | last post by:
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in Python, and I'm running into a problem: the same '#' character introduces...
1
2169
by: Sagaert Johan | last post by:
Hi Is there a constant i could use to force conditional compilation based on whether i compile for CF or the Full NET framework ? Johan
10
1746
by: VK | last post by:
Taking into account many new features in JavaScript1.6 and JavaScript1.7 which are syntactically incompatible with Javascript versions run on other browsers: would it be reasonable to propose as...
0
7108
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
6967
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
7142
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
7181
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
7352
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
5445
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,...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
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 ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.