473,386 Members | 1,821 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,386 software developers and data experts.

Single source code to compile over .NET 1.0, 1.1, 2.0 and CF

Hi everyone,

I have a .NET 1.1 application ready to be ported on .NET 2.0.

With some of the features made obsolete in 2.0 and the new recomended
methods are not available in .NET 1.1, It leaved me with a question in mind:

How come I conditionally compile my application with .NET 1.1 and 2.0 ?

An example of obsolete method in 2.0 is:
//-------------------------------------------------------------------
// .NET 1.1: OK, .NET 2.0: Warning, Property
ConfigurationSettings.AppSettings is obsolete !
string szNewKbAddr =
System.Configuration.ConfigurationSettings.AppSett ings[AppConstant.KEY_NEW_K
B_ADDRESS];

// .NET 1.1: Error, .NET 2.0: OK
string szNewKbAddr =
System.Configuration.ConfigurationManager.AppSetti ngs[AppConstant.KEY_NEW_KB
_ADDRESS];
//-------------------------------------------------------------------
I have used the code block similar to below, for conditional compilation of
code for .NET 1.1 and .NET CF:
//-------------------------------------------------------------------
#if(_WIN32_WCE)
... ... .NET CF specific code ... ...
#else
... ... .NET 1.1 specific code ... ...
#endif
//-------------------------------------------------------------------

Do we have any solution, to either conditionally compile the single source
code application on different versions of .NET ( 1.1 and 2.0 ) ?
OR- any other solution please ?

Thanks ...

* (Vipul)() ;
Mar 10 '06 #1
2 1427
Vipul Pathak wrote:
Hi everyone,

I have a .NET 1.1 application ready to be ported on .NET 2.0.

With some of the features made obsolete in 2.0 and the new recomended
methods are not available in .NET 1.1, It leaved me with a question
in mind:

How come I conditionally compile my application with .NET 1.1 and 2.0
?

An example of obsolete method in 2.0 is:
//-------------------------------------------------------------------
// .NET 1.1: OK, .NET 2.0: Warning, Property
ConfigurationSettings.AppSettings is obsolete !
string szNewKbAddr =
System.Configuration.ConfigurationSettings.AppSett ings[AppConstant.KEY
_NEW_K B_ADDRESS];

// .NET 1.1: Error, .NET 2.0: OK
string szNewKbAddr =
System.Configuration.ConfigurationManager.AppSetti ngs[AppConstant.KEY_
NEW_KB _ADDRESS];
//-------------------------------------------------------------------
I have used the code block similar to below, for conditional
compilation of code for .NET 1.1 and .NET CF:
//-------------------------------------------------------------------
#if(_WIN32_WCE)
... ... .NET CF specific code ... ...
#else
... ... .NET 1.1 specific code ... ...
#endif
//-------------------------------------------------------------------

Do we have any solution, to either conditionally compile the single
source code application on different versions of .NET ( 1.1 and 2.0 )
? OR- any other solution please ?

Thanks ...


Create nmake files and pass a define, like NET20. In the source, you
place
#if NET20
//... .net 20 specific
#endif
#if NET11
//... .net 11 specific
#endif

statements.

Example: (makefile_20)
SOURCES=AssemblyInfoDotNet20.cs DynamicQueryEngine.cs
SqlServerSpecificCreator.cs

REFERENCES=SD.LLBLGen.Pro.ORMSupportClasses.NET20. dll
REFDIR=..\ORMSupportClasses\DotNET2.0\bin\

all : $(SOURCES)
csc /t:library
/out:DotNET2.0\bin\SD.LLBLGen.Pro.DQE.SqlServer.NET 20.dll
/doc:DotNET2.0\bin\SD.LLBLGen.Pro.DQE.S
qlServer.NET20.xml /d:TRACE,DOTNET20 /o /lib:$(REFDIR) /r:$(REFERENCES)
$(SOURCES)

debug : $(SOURCES)
csc /t:library /debug
/out:DotNET2.0\bin\SD.LLBLGen.Pro.DQE.SqlServer.NET 20.dll
/d:TRACE,DEBUG,DOTNET20 /lib:$(R
EFDIR) /r:$(REFERENCES) $(SOURCES)

clean:
del /Q DotNET2.0\bin\SD.LLBLGen.Pro.DQE.SqlServer.NET20.*
and I start this with a simple .cmd file:
mkdir DotNET2.0\bin
nmake /nologo /f makefile_20 clean
nmake /nologo /f makefile_20

Frans

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Mar 10 '06 #2

"Vipul Pathak" <vpathak_[RemoveThisPart]_@impetus.co.in> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
Hi everyone,

I have a .NET 1.1 application ready to be ported on .NET 2.0.

With some of the features made obsolete in 2.0 and the new recomended
methods are not available in .NET 1.1, It leaved me with a question in
mind:

How come I conditionally compile my application with .NET 1.1 and 2.0 ?


Obsolete doesn't mean that they wont work.

I would just use the obsolete methods and ignore the warnings - you are less
likely to get version specific bugs that way.
Mar 11 '06 #3

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

Similar topics

2
by: LP | last post by:
Hi, I have a site which runs on .Net technology. The site is already deployed and running. I need to change 1 file for some small enhancement. Please tell me, how can I compile that 1 file and...
10
by: Tim Mulholland | last post by:
My company is about to begin working on an ASP.NET application. There are going to be two primary developers working on this project. It will be a fairly deep project (lots of lines of code) but...
3
by: LP | last post by:
Hi, I have a site which runs on .Net technology. The site is already deployed and running. I need to change 1 file for some small enhancement. Please tell me, how can I compile that 1 file and...
3
by: Claudio Pacciarini | last post by:
Hi everyone, I have a question about .NET code sharing and reuse, and also about application design best practices / guidelines. Currently, we have many different .NET projects in source...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.