PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Code that compiles under both ASP.NET 1.1 and 2.0?

 
 
wizofaus@hotmail.com
Guest
Posts: n/a
 
      6th Feb 2007
Has anyone successfully managed to work out how to get ASP pages to
compile under both 1.1 and 2.0? Basically I'm in the final stages
before deploying a version of an application that will be using 1.1,
and still making occasional fixes, but I'm also trying to move over
to .NET 2.0 for the next version. The biggest problem I've hit is the
new compilation models. From what I've read, .NET 2.0 is supposed be
able to support the old "codebehind" compilation model for .NET 1.1
that doesn't require partial classes etc., but the only way I've been
able to get it to work is to change the .aspx @page directive to use
"Src=" instead of "CodeBehind=". Without this I get a "Could not load
type 'xxx'" error for every page using Codebehind. But doing this
causes it fail with strange runtime errors under .NET 1.1 (mainly to
do with types being defined in multiple places).
The other alternative was use wrap the "partial" keyword, plus the
page control variable definitions not needed under .NET 2.0 in an #if,
and have both the "Codebehind" AND "Codefile" directives in the ASPX
pages - .NET 2.0 appears to ignore the former, and .NET 1.1 the
latter, so I believe this will actually work, but I'm not 100%
confident by any means, and it sure looks ugly having code like:

public
#if NET20
partial
#endif
class MyPage : System.Web.UI.Page
{
#if !NET20
public TextBox TextBox1;
public TextBox TextBox2;
#endif
}

all over the place!

Then there's the issue of code that needs to be in the App_Code
directory...although I can deal with that via the Source Control
system relatively easily.

I expect to be fixing bugs in the 1.1 version for at least a few weeks
yet, and having to continally manually apply them to the 2.0 version
seems theoretically more painful than trying to stick with a single
code version (note that I'm not planning on making functionality
changes to the 2.0 version for a while, otherwise obviously I would
need two code branches), but I suspect that MS haven't exactly made
this easy to achieve, for whatever reason.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      6th Feb 2007
If you want more interoperability between 1.1 and 2.O, use the Web
Application Project model instead of the original WebSite model in ASP.NET
2.0.
99% of 1.1 code WILL compile just fine in .NET 2.0.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"(E-Mail Removed)" wrote:

> Has anyone successfully managed to work out how to get ASP pages to
> compile under both 1.1 and 2.0? Basically I'm in the final stages
> before deploying a version of an application that will be using 1.1,
> and still making occasional fixes, but I'm also trying to move over
> to .NET 2.0 for the next version. The biggest problem I've hit is the
> new compilation models. From what I've read, .NET 2.0 is supposed be
> able to support the old "codebehind" compilation model for .NET 1.1
> that doesn't require partial classes etc., but the only way I've been
> able to get it to work is to change the .aspx @page directive to use
> "Src=" instead of "CodeBehind=". Without this I get a "Could not load
> type 'xxx'" error for every page using Codebehind. But doing this
> causes it fail with strange runtime errors under .NET 1.1 (mainly to
> do with types being defined in multiple places).
> The other alternative was use wrap the "partial" keyword, plus the
> page control variable definitions not needed under .NET 2.0 in an #if,
> and have both the "Codebehind" AND "Codefile" directives in the ASPX
> pages - .NET 2.0 appears to ignore the former, and .NET 1.1 the
> latter, so I believe this will actually work, but I'm not 100%
> confident by any means, and it sure looks ugly having code like:
>
> public
> #if NET20
> partial
> #endif
> class MyPage : System.Web.UI.Page
> {
> #if !NET20
> public TextBox TextBox1;
> public TextBox TextBox2;
> #endif
> }
>
> all over the place!
>
> Then there's the issue of code that needs to be in the App_Code
> directory...although I can deal with that via the Source Control
> system relatively easily.
>
> I expect to be fixing bugs in the 1.1 version for at least a few weeks
> yet, and having to continally manually apply them to the 2.0 version
> seems theoretically more painful than trying to stick with a single
> code version (note that I'm not planning on making functionality
> changes to the 2.0 version for a while, otherwise obviously I would
> need two code branches), but I suspect that MS haven't exactly made
> this easy to achieve, for whatever reason.
>
>

 
Reply With Quote
 
wizofaus@hotmail.com
Guest
Posts: n/a
 
      6th Feb 2007
On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.com> wrote:
> If you want more interoperability between 1.1 and 2.O, use the Web
> Application Project model instead of the original WebSite model in ASP.NET
> 2.0.
> 99% of 1.1 code WILL compile just fine in .NET 2.0.
> Peter
>

Sounds exactly like what I want. I'm just installing SP1 now
actually, which apparently includes it. I take it there are no real
disadvantages to using this, given I'm quite happy with the .NET 1.1
compilation model for my particular project?

 
Reply With Quote
 
wizofaus@hotmail.com
Guest
Posts: n/a
 
      6th Feb 2007
On Feb 6, 2:10 pm, wizof...@hotmail.com wrote:
> On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]<pbromb...@yahoo.yabbadabbadoo.com> wrote:
> > If you want more interoperability between 1.1 and 2.O, use the Web
> > Application Project model instead of the original WebSite model in ASP.NET
> > 2.0.
> > 99% of 1.1 code WILL compile just fine in .NET 2.0.
> > Peter

>
> Sounds exactly like what I want. I'm just installing SP1 now
> actually, which apparently includes it. I take it there are no real
> disadvantages to using this, given I'm quite happy with the .NET 1.1
> compilation model for my particular project?


I did hit two minor issues...one was that it wasn't copying my CSS
files to the deployment location (I had to mark them explicitly to be
copied), and the other was that when debugging under VS.NET 2005 it
apparently always uses NTLM authentication, which was causing problems
with my own authentication code (I was prematurely checking for the
LOGON_USER server variable), but both problems were easily fixable,
and it all seems to be working fine. Pleasantly surprised that MS
apparently saw the need to make the upgrade path from 2003 somewhat
simpler!

 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      6th Feb 2007
Heh. Actually they didn't see the need until after VS 2005 was out and
developers started screaming bloody hell. :-)
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"(E-Mail Removed)" wrote:

> On Feb 6, 2:10 pm, wizof...@hotmail.com wrote:
> > On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]<pbromb...@yahoo.yabbadabbadoo.com> wrote:
> > > If you want more interoperability between 1.1 and 2.O, use the Web
> > > Application Project model instead of the original WebSite model in ASP.NET
> > > 2.0.
> > > 99% of 1.1 code WILL compile just fine in .NET 2.0.
> > > Peter

> >
> > Sounds exactly like what I want. I'm just installing SP1 now
> > actually, which apparently includes it. I take it there are no real
> > disadvantages to using this, given I'm quite happy with the .NET 1.1
> > compilation model for my particular project?

>
> I did hit two minor issues...one was that it wasn't copying my CSS
> files to the deployment location (I had to mark them explicitly to be
> copied), and the other was that when debugging under VS.NET 2005 it
> apparently always uses NTLM authentication, which was causing problems
> with my own authentication code (I was prematurely checking for the
> LOGON_USER server variable), but both problems were easily fixable,
> and it all seems to be working fine. Pleasantly surprised that MS
> apparently saw the need to make the upgrade path from 2003 somewhat
> simpler!
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
What CLR/JIT version compiles my 1.1 IL code ? =?Utf-8?B?Z2VuYyB5bWVyaQ==?= Microsoft Dot NET Framework 5 8th Jun 2007 04:32 PM
error in code that writes and compiles a dll on the fly help please on on via DotNetMonster.com Microsoft Dot NET Compact Framework 1 24th Mar 2005 06:19 PM
Code compiles but Excel ERROR Roba Microsoft Excel Programming 2 6th May 2004 08:29 PM
code compiles c++ 6.0, not in c++ .NET Steve Richter Microsoft VC .NET 14 29th Oct 2003 01:10 AM
code compiles in 6.0 and doesn't compile in 7.0 rvan Microsoft VC .NET 1 16th Oct 2003 10:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:17 PM.