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

Discussion in 'ASP .Net' started by Vipul Pathak, Mar 10, 2006.

  1. Vipul Pathak

    Vipul Pathak Guest

    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.AppSettings[AppConstant.KEY_NEW_K
    B_ADDRESS];

    // .NET 1.1: Error, .NET 2.0: OK
    string szNewKbAddr =
    System.Configuration.ConfigurationManager.AppSettings[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)() ;
     
    Vipul Pathak, Mar 10, 2006
    #1
    1. Advertising

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

    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.AppSettings[AppConstant.KEY
    > _NEW_K B_ADDRESS];
    >
    > // .NET 1.1: Error, .NET 2.0: OK
    > string szNewKbAddr =
    > System.Configuration.ConfigurationManager.AppSettings[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.NET20.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.NET20.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#)
    ------------------------------------------------------------------------
     
    Frans Bouma [C# MVP], Mar 10, 2006
    #2
    1. Advertising

  3. Vipul Pathak

    Vipul Pathak Guest

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

    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.AppSettings[AppConstant.KEY
    > > _NEW_K B_ADDRESS];
    > >
    > > // .NET 1.1: Error, .NET 2.0: OK
    > > string szNewKbAddr =
    > > System.Configuration.ConfigurationManager.AppSettings[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.NET20.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.NET20.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#)
    > ------------------------------------------------------------------------
     
    Vipul Pathak, Mar 10, 2006
    #3
  4. "Vipul Pathak" <vpathak_[RemoveThisPart]> 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.
     
    Nick Hounsome, Mar 11, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris
    Replies:
    1
    Views:
    13,767
    Oisin
    Mar 24, 2006
  2. Nagaraj
    Replies:
    1
    Views:
    924
    Lionel B
    Mar 1, 2007
  3. fAnSKyer
    Replies:
    2
    Views:
    569
    Alf P. Steinbach
    Jun 7, 2009
  4. Water Cooler v2
    Replies:
    2
    Views:
    519
    Water Cooler v2
    Apr 18, 2006
  5. Justin Ezequiel
    Replies:
    4
    Views:
    86
    Gregory Ewing
    Apr 26, 2014
Loading...

Share This Page