Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Single source code to compile over .NET 1.0, 1.1, 2.0 and CF

Reply
Thread Tools

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

 
 
Vipul Pathak
Guest
Posts: n/a
 
      03-10-2006
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)() ;


 
Reply With Quote
 
 
 
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      03-10-2006
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
/outotNET2.0\bin\SD.LLBLGen.Pro.DQE.SqlServer.NET 20.dll
/docotNET2.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
/outotNET2.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#)
------------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Vipul Pathak
Guest
Posts: n/a
 
      03-10-2006
Thanks a lot .....

* (Vipul)() ;


"Frans Bouma [C# MVP]" <> wrote in message
news...
> 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
> /outotNET2.0\bin\SD.LLBLGen.Pro.DQE.SqlServer.NET 20.dll
> /docotNET2.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
> /outotNET2.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#)
> ------------------------------------------------------------------------



 
Reply With Quote
 
Nick Hounsome
Guest
Posts: n/a
 
      03-11-2006

"Vipul Pathak" <vpathak_[RemoveThisPart]_@impetus.co.in> wrote in message
news:...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile the following source code in VC6// I have error inVC++6 but compile ok in GCC fAnSKyer C++ 2 06-07-2009 07:57 AM
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
Anyone who can help me to compile a source code package under the Solaris platform? jing C++ 1 12-08-2005 03:19 PM
Java classes are always defined inside a single source code file ?! Razvan Java 2 07-15-2004 02:41 PM



Advertisments