Migrating an ASP.NET 2.0 Beta 1 App to Beta 2: Common Problems and Their Solutions

ASP.NET 2.0 is currently in beta 2 version. Those of you who have been curious to know about the new features in 2.0 and had installed the beta 1 version would have found that many of the ASP.NET applications written in beta 1 don't even compile in beta 2. This article will help identify the common compile time errors and the changes required to fix them.

Changes in Page Attribute Names

In the aspx file's @Page directive, two common attributes used are to specify the code-behind file and to specify the class name for the page. The names for these attributes have changed as follows:

Beta 1

WebForm1.aspx: <%@ page CompileWith="webform1.aspx.cs"
                        ClassName="WebForm1 %>

Beta 2

WebForm1.aspx: <@ page CodeFile=webform1.aspx.cs
                       Inherits=WebForm1 %>

Compilation Error Received

The CompileWith/ClassName attributes in the compilation model are
no longer supported.

Explicitly Specifying the Base Class

When creating master pages and Web forms through Visual Studio 2005 beta 1, the form class's base class isn't specified. When compiling this code in beta 2, compile errors are gotten.

Beta 1

MasterPage.aspx.cs: public partial class MasterPage_master { }
   // note there is no base class specified
WebForm1.aspx.cs: public partial class WebForm1 { }
   // note there is no base class specified

Beta 2

MasterPage.aspx.cs: public partial class MasterPage_master :
   System.Web.UI.MasterPage {}
WebForm1.aspx.cs: public partial class WebForm1 :
   System.Web.UI.Page {}

Compilation Error Received

error CS0115:ASP.MasterPage_master.FrameworkInitialize()':
   no suitable method found to override.
Could not find any attribute 'marginheight' of element 'body'

When Using Master Pages, Explicitly Mark the Event Handlers as Protected

Visual Studio 2005 beta 1 does not put any access modifiers for event handlers. Due to this, they are treated as private in beta 2, generating compile time errors.

Beta 1

WebForm1.aspx.cs: void GridView1_Init(object sender, EventArgs e)
   // note access modifier missing

Beta 2

WebForm1.aspx.cs: protected
                  void GridView1_Init(object sender, EventArgs e)

Compilation Error Received

error CS0122: 'TestDetails_aspx.GridView1_Init(object,
               System.EventArgs)' is inaccessible due to its
               protection level.

Change in the Theme Directory Name

In ASP.NET 2.0, the theme files are stored in a special directory. In beta 1, this folder was named "Themes;" in beta 2, the name has been changed to "app_themes." The names of other special folders have also been changed.

Beta 1

Theme folder :    /Themes
Database folder : /Data
Code folder :     /Code

Beta 2

Theme foler :     /app_themes
Database folder : /app_data
Code folder :     /app_code

Runtime Error Received

- Invalid theme or stylesheettheme value.
- Theme 'theme-name' cannot be found in the application or global
  theme directories.

Some Useful Links

Visual Studio 2005 Developer Center (this also has a link to "Get Visual Studio 2005 Beta 2"): http://lab.msdn.microsoft.com/vs2005/

If you want to understand why the changes described in this article were made to Beta 2: http://msdn.microsoft.com/asp.net/beta2/beta2update.aspx



About the Author

Manoj Agarwal

Manoj Agarwal has over a decade of industry experience on a wide spectrum of technologies. He currently runs a software company called Falconsoft Systems which specializes in consulting, application development and training mainly in Microsoft .NET. Manoj was among the top-10 winners at the nationwide Microsoft Technology Adopter Challenge.

Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • CentreCorp is a fully integrated and diversified property management and real estate service company, specializing in the "shopping center" segment, and is one of the premier retail service providers in North America. Company executives travel a great deal, carrying a number of traveling laptops with critical current business data, and no easy way to back up to the network outside the office. Read this case study to learn how CentreCorp implemented a suite of business continuity services that included …

Most Popular Programming Stories

More for Developers

RSS Feeds