Migrating from .NET 1.1 to 3.5

Everybody likes to embrace the latest technology. We start hunting for it as soon as we realize the existing tool/technology is growingolder or not delivering up to the expectations. However, We should not forget the difficulties that come across the transition path. Sometimes, tools fail to deliver the way in which they are marketed. For me, one such tool was Visual Studio 2008.

I recently migrated a fairly big enterprise application from .NET 1.1 to 3.5. I was very happy as the decision was in the favor of both business as well as the development team. I decided to play intelligently and migrated a separate copy of the application beforehand to use it as a reference in future. Obviously, I was supposed to face problems as migration directly from 1.1 to 3.5 is not suggested on the forums, but accroding to my experience, it is not a big deal as long as your application has a good architecture and you know how to use Visual Studio Find and Replace utility:).

The purpose of writing this post is to inform the readers of the steps they should take to avoid spending too much time on migration. I encountered following errors before and after installing Visual Studio 2008 SP1. Make sure you run though the list below before you migrate your web application to .NET 3.5.

  • Thevery first problem you might face is that the .designer.vb has not been generated for all of the web pages in your application after running the automatic migration wizard for the first time. You need to right click on the project and select "Convert to Web Application" many times until you see all of the designer in the project directory.
  • If you stop the migration process half way through due to any reason, then make sure you follow the above step again or IDE will show you designer files excluded from project.

  • Stopping the process half way through might also show you some *.vb files with *.vb.old extension. These are the files that got successfully created last time. You can simply delete them anytime duringor after the exercise.

  • At one point, upon compiling the project, I got many "[Variable_Name]not declared" errors. After digging into the code, I spotted some of the class declarations looked like [Partial] Public Class [Class_Name]. If you witness the same thing then all you need to do is to replace [Partial], which is not a key word in .NET, with Partial using Visual Studio Find and Replace in Files. You can press Ctrl+Shift+H for fire up the utility.

  • The biggest of all problems I faced immediately after installing VS2008 SP1 was the way IDE created the designer files. I started receiving hundred of "[Variable_Name] is already declared as 'Protected[Variable_Name] As [Class_Name]' in this class" errors. Upon investigation, I found that Visual Studio 2008 IDE didn't remove control declarations from *.vb file after creating the same in *.designer.vbwhile converting to web application resulting in a number of multiple declaration errors. I couldn't find any shortcut to get rid of that and had to manually do it for every file.
  • One of the syntax changes that has been introduced in .NET 3.5 is the way it generates child control declarations in HTML. While using DataRepeater and DataGrid on a web page, following changes caught my attention:

    repeater1__ctl0_checkbox1 (.NET 1.1)
    repeater1_ctl00_checkbox1 (.NET 3.5)

  • One of the good things about the latest version of .NET framework is the availability of security features like Event Validataion and Request Validataion. The former reduces the risk of unauthorized postback requests and callbacks and the later prevents from cross site scripting (XSS) by rejecting any HTML in form post. Although both of the features can be disabled at the page level, but it is not recommended generally for security reasons.I took advantage of the event validation by overriding the Render method of the base page:
    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
    ClientScript.RegisterForEventValidation([control].UniqueID, String.Empty)
    MyBase.Render(writer)
    End Sub
    However, for request validataion, I had to disable it as my application needs to accept some HTML elements. Check out the below link for more details:
    Protecting Against Script Exploits in a Web Application

So much, so far. I will keep posted more erros as they come. If you have faced any error which is not in the above list then do share it with me, I will add them here.

5 comments:

a commoner said...

Dear Irfan,

I have come across your view and experience about migrating from 1.1 to 3.5, which I may say, found it extremely handy. I have a similar task at hand and would like you to share the migration process. Did you migrate directly from v1.1 to v3.5 or did u go from v1.1 to 2.0 and from v2.0 to v3.5. Awaiting your reply

irfan said...

Hi Arun,

Thanks that you found it useful. While I was going through this similar experience, I had both of the options in hand that you mentioned however, I preferred to take the approach which I have explained in the article that is direct migration from 1.1 to 3.5. This direct migration may seem a daunting task at first, but it turns out to be a straightforward if you have tried it on smaller project.

Let me know how can I help you.

HTH,

Unknown said...

Hi Irfan,

Very handy information but needs to some more things apart from Design changes

I haven't seen any informtion related to the framewrok changes which are huge effect in 1.1 to 3.5 Framework migration, especially while using Oracle database as a background.

Thanks,
-Basha

irfan said...

Hi Shaikh,

There are certainly a lot of framework changes as well apart from design changes as you rightly said. However, I must say that the intention of this post was just to highlight the migration atrocities. Thanks

HTH,

Macrosoft said...

Good advice for .net migration.

Visual FoxPro to .Net

Post a Comment