Converting Projects from Visual Studio 2003 to Visual Studio 2005

Converting Projects from Visual Studio 2003 to Visual Studio 2005

This article is intended for most Microsoft development shops using the standard MS technology. It discusses the considerations that need to be taken into account when migrating existing VS2003 applications to VS2005. These considerations would include:

  1. The strategy to take, in terms of maintaining two versions of the product (VS2003 and VS2005) on Visual SourceSafe while the organizations is in its transition phase.
  2. The step-by-step process of migrating a Windows application from VS2003 to VS2005 and possible issues that may be encountered.
  3. The step-by-step process of migrating a Web application from VS2003 to VS2005 and possible issues that may be encountered.

Managing VS2003 and VS2005 Projects in SourceSafe

When converting VS2003 projects to VS2005, you need to ensure there is a backup of the original project in SourceSafe. For this reason, all VS2005 projects in this article will be housed in the Dev-2005 folder on VSS; and all existing VS2003 projects will reside in the Dev folder in VSS. Following is a best practice method of moving within VSS

Step 1: Imitating a share on Visual SourceSafe

Launch VSS; right-click on the DEV-20005 folder and bring up the context menu. Select the shared menu item on the context menu. This should launch the "share with" window as shown below.

Step 2: Select the folder to be shared

Drill down to the folder that you want to move to DEV 2005. Be certain to check on the "Branch after share" check box. This ensures a separate copy of the project folder is created on the DEV 2005 folder and not just a pointer to the existing copy. Click the share button when you're ready. This will bring up the "Share" window.

Step 3: Complete the sharing process

The "Share" window allows you to modify the name of the project and to add comments in regards to the sharing. Be sure to check on the Recursive checkbox. Click the OK button; this then should generate a separate copy of the project folder under the DEV 2005 directory.

  1. You will want to perform these steps before migrating both Win and Web apps.
  2. Until Current as an organization has completely moved to 2.0, you should pull down the working directory for DEV and DEV-2005 so that you will be able to provide support for both VS2003 and VS2005 apps.

Migrating a VS 2003 Win Project to a VS 2005 Win Project

Migrating your VS 2003 Win apps to VS 2005 simply involves backing up your VS 2003/1.1 solution first!!! Then, open your Visual Studio 2002 or 2003 project/solution in Visual Studio 2005. A conversion wizard will convert the project/solution to 2005. Compile the code, and you will now have a .NET 2.0 application!

The following is a step-by-step breakdown of the process.

Step 1: Initiate the migration process

Launch VS 2005 and drill down to the menu item as indicated above.

Step 2: Select the solution/project to migrate

Select the VS 2003 Solution and/or project that you want to migrate to VS 2005. Now, click Open.

Step 3: Welcome screen

The conversion wizard welcome window should appear. Click Next if there are no other issues.

Step 4: Back up existing project

Accept the default backup option if you do not have a pre-existing backup plan. Click Next.

Step 5: Confirmation screen

The "ready to convert" window will appear, listing all the actions that are about to be taken. Click on the Finish button.

Step 6: Result of conversion

VS 2005 IDE should appear with a results page indicating the results of the conversion process.

Migrating a Visual Studio .NET 2003 Web Project to a Web Application Project

This section walks you through the process of converting an existing Visual Studio .NET 2003 Web project to a Web application project in Visual Studio 2005. The Web application project model uses the same conceptual approach as a Web project in Visual Studio .NET 2003, including a project file to include and exclude files, compilation to a single assembly, and so on. In general, Web application projects do not require any architectural changes after the conversion.

As in the preceding section, this section assumes that you are working in C#. The steps for working with Visual Basic are very similar, but file names and some of the code will differ.

Step 1: Install the Visual Studio 2005 Web Application Project preview

Be sure you have installed Web Application Projects in Visual Studio 2005 by following the steps highlighted in this link.

Step 2: Back up your Visual Studio .NET 2003 projects

Make absolutely sure to save a backup of your Visual Studio .NET 2003 Web projects and solutions before attempting any migration. The following steps have been tested using the preview version of Web Application Projects. However, there could still be issues, and you might need to restore the Visual Studio .NET 2003 solution.

Step 3: Open and Verify your Visual Studio .NET 2003 Web Project

Before migrating a project, open your existing Visual Studio .NET 2003 solution, compile it, and then run it. Spending a few minutes to verify that everything works before you migrate can save trouble later, especially if the cause of errors is a last-minute directory change or something similar.

Step 4: Migrate the Solution to Visual Studio 2005

Close the solution in Visual Studio .NET 2003, and then start Visual Studio 2005. On the File menu, click Open File, and then browse to the .sln file for the solution you want to migrate. This launches the Visual Studio 2005 Conversion wizard:

Click Next to proceed through the wizard, accepting all defaults. Visual Studio 2005 will convert the solution and its contained project files to use the MSBuild format, which is the new project file format in Visual Studio 2005.

As part of the migration, Visual Studio 2005 generates an XML-based log file that provides a summary of the conversion process, flagging any issues encountered during migration. By default, the conversion log file is saved in the same directory as the .sln file. If you have issues later when compiling the project, you might need to refer back to the conversion log file.

Step 5: Verify in Visual Studio 2005

After the solution and project files are upgraded to Visual Studio 2005 format, validate that your application builds without errors and runs as expected. At this point, the most common errors or warnings will be of these types:

  • Conflicts with names in introduced in the .NET Framework version 2.0
  • Warnings about using obsolete members

To fix naming conflicts, you either can fully qualify existing names with a namespace to remove ambiguity, or rename the members so they do not conflict.

If you see a warning about using obsolete members, the warning message usually will suggest alternative APIs to use. In these cases, you can continue to use the obsolete members in the 2.0 version of the .NET Framework. However, the members will be removed in the next major release of the .NET Framework, so it is a good practice to remove the members and substitute the suggested alternatives.

When running your Web application, you might see an error that says "Directory Listing Denied" that suggests that a virtual directory does not allow its contents to be listed. If you see this error message, do the following:

  1. Close the browser.
  2. In Solution Explorer, right-click the application's start page and then click Set as Start Page to ensure that the correct page is invoked when the application runs.
  3. Run the application again.

Step 6: Convert code-behind classes to partial classes

As noted earlier, in Visual Studio 2005, Web application projects use partial classes to store designer-generated code. These classes are stored in a separate file from the code-behind file. By default, the Visual Studio 2005 Web project conversion wizard does not create a *.designer.cs (or *.designer.vb) file for Web pages (.aspx files) or user controls (.ascx files). Instead, the code will look and work just like it did in Visual Studio .NET 2003.

Note: The wizard makes the minimum number of changes to the code files during migration to help ensure a smooth conversion to Web application projects in Visual Studio 2005.

You can keep your code in this format. If you do, you must manually update the control field declarations in the code-behind files, but everything else will work fine in Visual Studio 2005.

To take advantage of the editor's ability to maintain field declarations in generated code, you should update your pages and controls to use the partial-class model introduced in ASP.NET 2.0. Partial classes make it easier to organize the generated code and custom code for your code-behind files.

To migrate your code to use partial-class model, first make sure that your code compiles without errors. Then, in Solution Explorer, right-click the project name and click Convert to Web Application. This command iterates through each page and user control in the project, moves all control declarations to a .designer.cs file, and adds event handler declarations to the server-control markup in the .aspx and .ascx files.

Note: Another option is to use the Convert to Web Application command on individual pages. You might do this first on a few pages if you want to watch closely the changes made for each page before applying the change to the entire application.

When the process has finished, check the Task List window to see whether any conversion errors are reported. If the task list displays errors, right-click the relevant page in Solution Explorer and choose View Code and View Code Gen File to examine the code and fix problems. Note that errors and warnings that appear in the Task List window persist between Visual Studio sessions. After you have fixed errors listed in the window, you can clear items from the task list.

Note: The Convert to Web Application command cannot be undone in Visual Studio. The best method for reverting the changes is to restore from a backup of the Visual Studio .NET 2003 project, and then to re-run the Visual Studio 2005 migration as described in Step 4 above.

Now, recompile your project to ensure it compiles without errors. A possible source of errors is if you have modified the control declarations in a code-behind class and the conversion wizard mishandled your changes.

From this point, when you add new pages into your Web project, they will by default use the partial-class template.

Step 7: Examine and Resolve XHTML Compliance Issues

By default, Visual Studio 2005 generates and validates XHTML-compliant markup. This helps you build Web applications that are standards compliant and helps minimize issues with browser-specific rendering. Visual Studio .NET 2003 did not generate XHTML-compliant markup, so you might see validation and rendering issues with pages created in Visual Studio .NET 2003.

Note: Validation errors are informational only and are flagged as warnings. Validation errors do not prevent a page from running.

If you do not want to see validation errors, switch the HTML validation setting from XHTML Transitional to Internet Explorer 6.0 (which was the Visual Studio .NET 2003 default setting). In the Tools menu, click Options. In the Options dialog box, open the Text Editor node, then the HTML node, and then the Validation node. In the Target list, select Internet Explorer 6.0, and then unselect the Show Errors check box. Note that this does not fix XHTML validation errors; it simply switches the validation schema to one that is more compatible with the way markup was generated by Visual Studio .NET 2003, and it suppresses validation warnings.

You also can add the following section to your project's Web.config file, which causes ASP.NET to render legacy (non-XHTML compliant) markup from server controls:

   <xhtmlConformance mode="Legacy" />

This will avoid the slight rendering differences you might see between pages displayed using ASP.NET 1.1 and using ASP.NET 2.0. For more information, see ASP.NET and XHTML in the MSDN Library.

Step 8: Creating a new virtual directory for the migrated VS2005 Web project

You will want to create a new virtual directory for your newly migrated Web app by bringing up the properties screen of your project and clicking the Web tab. On the Web form, you will see a text box where the path of your new virtual dir can be specified and a "Create Virtual Directory" button that then will create the directory.

If you are planning to run both VS2003 and VS2005 versions of the app on your machine (which will be the case until you are fully migrated), you will want to restore the backup of the VS2003 virtual directory that was created when the one for VS2005 was created. Alternatively, you can simply launch the VS2003 version of the app and it will detect the virtual dir as not being present and create it again.


  • 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: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds