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

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 1938

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
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
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
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
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
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
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
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
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
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
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
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
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...
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.