Software Development

Don't sweat migrating legacy .NET projects to Visual Studio 2008

Visual Studio 2008 automates the conversion process and allows you to continue working with older versions of the .NET Framework. Tony Patton provides an overview of what a migration to Visual Studio 2008 entails.

I'm always a bit apprehensive when moving to a new development tool or a new version of an existing tool because of the possibility of breaking existing code and projects. Little did I know that migrating to Visual Studio 2008 would be such a breeze.

Visual Studio 2008 automates the conversion process and allows you to continue working with older versions of the .NET Framework. I migrated to Visual Studio 2008, and I have not encountered any problems.

I'll try to ease your concerns about migrating to Visual Studio 2008 with this overview of what a migration entails. (Note: If you're working in a team environment, all developers will need to use it.)

Conversion

Visual Studio 2008 offers a complete replacement for its predecessors. It has a great new feature called multi-targeting, which allows you to develop solutions for multiple versions of the .NET Framework beginning with 2.0 and higher.

The IDE interface adapts to the targeted version. While it provides this flexibility, it uses its own project and solution format, which is incompatible with previous versions. Note that, once you convert a solution to Visual Studio 2008, you cannot open it in previous versions.

Solution files are text-based files with the familiar .sln file extension. Project files are XML-based (using the familiar file extensions according to the language used, with .csproj for C# and .vbproj for Visual Basic).

The following sample is a project file for an ASP.NET project.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ProjectExtensions>

<VisualStudio>

<FlavorProperties GUID="{001c5000-65df-11db-9384-00065a956f00}">

<WebProjectProperties>

<StartPageUrl>sample.aspx</StartPageUrl>

<StartAction>SpecificPage</StartAction>

<AspNetDebugging>True</AspNetDebugging>

<NativeDebugging>False</NativeDebugging>

<SQLDebugging>False</SQLDebugging>

<PublishCopyOption>RunFiles</PublishCopyOption>

<PublishTargetLocation></PublishTargetLocation>

<PublishDeleteAllFiles>False</PublishDeleteAllFiles>

<PublishCopyAppData>True</PublishCopyAppData>

<ExternalProgram></ExternalProgram>

<StartExternalURL></StartExternalURL>

<StartCmdLineArguments></StartCmdLineArguments>

<StartWorkingDirectory></StartWorkingDirectory>

<EnableENC>False</EnableENC>

<AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>

</WebProjectProperties>

</FlavorProperties>

</VisualStudio>

</ProjectExtensions>

</Project>

Using the conversion wizard

Visual Studio 2008's conversion wizard automates the process of converting a solution to the new IDE. The wizard appears when you open a solution in Visual Studio 2008 built with a previous version of Visual Studio. Figure A shows the initial window of the conversion wizard. Figure A

Figure A

Figure A: Visual Studio 2008 conversion wizard opening window

Converted solutions or projects are no longer compatible with Visual Studio versions prior to Visual Studio 2008. However, the projects may still use a previous version of the .NET Framework.

The conversion wizard automatically appears when an older solution is opened in Visual Studio 2008. The first step in the conversion process is the creation of a backup. (This is an optional step.)

The backup keeps a copy of the solution in its pre-converted state, so it can be used if you need to work with the solution in its version of Visual Studio. There may be significant delays, as files are copied during the backup process.

Conversion proceeds once a backup is created (the conversion process may take a few minutes depending upon the size of the project). If any problems are encountered during the conversion process, a conversion log is presented: otherwise, the conversion process continues.

Upon successful conversion, the wizard prompts you to upgrade the targeted version of the .NET Framework for the project, as Figure B demonstrates. This allows you to move to the .NET Framework 3.5. Any configuration (web.config, app.config, etc.) is modified, as well if you upgrade the framework used. Figure B

Figure B

Figure B: A successful conversion ends with a prompt to upgrade the .NET version.

There are a variety of problems that may arise in the conversion process that could result in an unsuccessful conversion. One problem I've seen repeatedly is the need to run the process as administrator when converting ASP.NET applications that use IIS, as opposed to the built-in Web server.

Problems may also occur if an application includes controls or extenders from the ASP.NET AJAX Control Toolkit, and you are upgrading to the latest version of the .NET Framework. You must upgrade to a new version of the toolkit in order to run with the .NET Framework 3.5.

If your environment includes a source-control system (which it should), all necessary files will be automatically checked out by the conversion wizard. The conversion will fail if a file cannot be exclusively checked out.

Batch conversion

One feature I especially like in Visual Studio 2008 is the support for batch conversion via the /Upgrade command-line switch for the Visual Studio 2008 executable (devenv.exe). This allows you to upgrade multiple projects or solutions via a simple command, or you may create a batch file with multiple commands.

Converting code after the fact

The multi-targeting feature introduced in Visual Studio 2008 is wonderful; it allows you to build solutions that use any version of the .NET Framework beginning with 2.0. If you choose not to convert a project's code to version 3.5 when using the conversion wizard, you can convert it later.

The target framework version is an option that is accessible via the properties of a project, as shown in Figure C. At this time, the target framework version allows you to choose one of these options: .NET Framework 2.0, .NET Framework 3.0, and .NET Framework 3.5. A project must be closed and reopened after its target .NET version has been changed. Figure C

Figure C

Figure C: Working with the target framework version of a project

Discuss your migration experience

Are you currently using Visual Studio 2008? Have you migrated projects to the new environment? What, if any, problems have you encountered with the migration? If you are still waiting to migrate projects to Visual Studio 2008, what is the main thing holding you back? Share your experience with the Visual Studio Developer community.

Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.

About

Tony Patton has worn many hats over his 15+ years in the IT industry while witnessing many technologies come and go. He currently focuses on .NET and Web Development while trying to grasp the many facets of supporting such technologies in a productio...

21 comments
Vibrate
Vibrate

I took a ASP .NET 2003 (.NET 1.1) application and converted it to an ASP .NET 2005 (.NEt 2.0) application using the Web Application Projects add-in provided for Visual Studio 2005. That went pretty well and now I am trying to convert the resulting VS 2005 ASP .NET 2.0 appliation to VS 2008 ASP .NET 3.5 and am getting the error. Please note that I am running VS 2008 Professional. Also the solution has two projects a dll and a web. The dll compiles fine but when I try to compile the web I get the error message: "The project file must be opened in the Visual Studio IDE and converted to the latest version before it can be built by MSBuild." Any and all help is appreciated.

din
din

i am trying to migrate from VS C++6 TO VS2008. The problem i am running into is with VS C++6 MFC .h files not allowed with VS2008. any idea how to get around this problem. my e-mail is dinattar@hotmail.com. Thanks. Din

edmicman1
edmicman1

I initially chose not to upgrade to .NET 3.5 when it prompted me, but tried it later. It was a .NET 2.0 web app that used the AJAX.NET (1.0 I think?) libraries. Converting to .NET 3.5 worked fine, but I ended up having to convert it back to .NET 2.0 because our web server that it would finally be running on is still on Windows 2000 and doesn't support .NET 3.5 :-/. Long story short, something with the AJAX.NET stuff got screwed up - after reverting back to 2.0 none of the AJAX stuff worked, it just degraded back to standard behaviors. I did some digging and ran across something about .NET 3.5 using it's own internal AJAX.NET libraries, and if you converted a project to that it would in turn use those libraries...which aren't available in 2.0 and for some reason it wouldn't automatically revert back to the old ones. I ended up finding an AJAX.NET 1.0 starter project or something that I had to install into VS2008 so that I could create .NET 2.0 projects with the old AJAX libraries. Anyone else run into something like this?

developer
developer

I understood Visual Studio 2008 does not work with SQL Server 2000

judexy22
judexy22

I have Visual Studio.net 2003 which has an issue with Vista Home Premium. Can I upgrade 2003 to VS 2008 ? Thanks to help. Judex Young. judexy22@hotmail.com

judexy22
judexy22

I have Visual Studio 2003 and Vista Home Premium. There are issues between them. Can I upgrade my Visual Studio 2003 to Visual Studio 2008 ? Is the 2008 version ok with Vista ? Thanks to help me Judex Young judexy22@hotmail.com

Wudpecker13
Wudpecker13

Tony-- thanks for keeping us informed. If it interests you, you might help some coders deal with two old problems-- 1)"C" programming fitting into C++ 2)Dealing with 8-bit graphic screens. Literally old problems. European Air War is a flight simulator released in the Fall of 1998. We have legal permission to update the code for this "Oldie But Goodie". And we have done just that-- with few good coders among us. Most of us have minimal programming skills and are still studying. One unsolvable problem is having 8-bit screens that many graphic cards no longer recognize. The only option we know of is to scrap the screen system and rebuild with at least 16-bits. That means losing those screens. Plus.... It has mixed "C" coding and C++ "Object-Oriented" modules. Any special way of handling that?

jagankumar
jagankumar

I have one query, what about the case when we migrate the project, and target version is set to framework 3.5, will this new application still works with framework 2.0 enviroment?

Justin James
Justin James

I have had good success with opening VS.Net 2005 projects in 2008 too! J.Ja

monty327
monty327

I experienced your same scenario, but have never been successful when attempting to continue development of my old VS 2005 applications created with AJAX Control Toolkit extenders. Our IT department will not be switching to framework 3.5 anytime soon, but they have purchased VS 2008 for our convenience. Although successfully able to get some of my apps to compile, one strange symptom is that some of the AJAX controls that I created cannot be seen in the graphical GUI (but still exist in the source) - like some gridviews that I put in an Update panel inside a Panel - for a modal popup extender. A checklist of "must accomplish" tasks would certainly help me get over this hump of having to stick with VS 2005, and be greatly appreciated. Thank you.

magillj
magillj

Thats right Pete - the AJAX 1.0 dlls are different between .net 2.0 and 3.5. Visual Studio shipped with the 3.5 libraries and not 2.0. As far as I know, there is no automatic conversion between the two. If anyone wants to continue to use MS AJAX with 2.0 they have to manually download them from ajax.asp.net and throw them in the Bin or GAC or whatever.

alaniane
alaniane

VS 2008 to recognize SQL Server 2000. However, it's possible that some procs may not work.

Justin James
Justin James

I've been running VS.Net 2008 on Vista since December, works great! In fact, VS.Net 2005 worked, but was a real hassle due to UAC, 2008 no longer has those issues. J.Ja

Justin James
Justin James

It might. It depends on whether or not you do anything 3.X specific or not, which is quite a lot of things. If you don't use anything 3.X specific, you should be able to re-target 2.0 without a problem. J.Ja

haasey
haasey

I love the theory of multi-targeting but it falls short. At least 70% of .net code is still 1.1. You should be able to also target 1.1. Also once you open a 2005 project (as you noted) everyone on the team must upgrade to 2008. Again short sighted by Microsoft. This is a huge issue for many shops, it's an all or nothing approach. The ideas are 1st class, the implementation leaves a lot to be desired.

Justin James
Justin James

... then don't use VS.Net 2008. The only reason to use 2008 if you're on 1.1 is to have a version of VS.Net that is Vista compatable. I may add, 2005 is not 1.1 compatable, so what's the complaint? I am always confused by people still on 1.1. 2.0 is a recompile for 1.1 code as far as I can tell. Does anyone have an idea why shops are reluctant to move to 2.0? Or 3.X for that matter? Just because you move to it doesn't mean you need to use any of it's existing functionality. J.Ja

Justin James
Justin James

I know what you mean about the big corp.s not allowing .Net 2.0 or 3.X to be installed. It's an attitude that has always baffled me. .Net CLRs & Frameworks install side-by-side, allowing an uplevel one to be installed doesn't break a thing, nor does it enable anything unless an app that uses it is installed. Blocking the uplevel .Nets simply blocks the install of certain apps, that's about it. I just don't see the purpose of blocking it. But it is a common thing. J.Ja

haasey
haasey

I like 2008 and like the fact that it can work with both frameworks with 1 IDE. I wanted all 1.1, 2.0, 3.0, and 3.5. One reason people don't go to 2.0 is corporate policy. Some fortune 500 companies wouldn't allow you to install 2.0 framework...or now more recently many won't have the 3.0 or 3.5 frameworks as of yet.

Rod Wittmier
Rod Wittmier

Some of my DEVs have all 3 versions (2003-net 1.1, 2005-net 2.0 and 2008-net 3.5) of Visual Studio running under XP with no problem. Clearly our choice is 2008, but do use the older versions to maintain projects that are not worth converting at this time.

alaniane
alaniane

because of some internal issues and the fact that the third party controls that we were using in our main app would not compile under 2.0. Cost was a big factor in not upgrading at the time. Recently, infrastructure upgrades are making it worth converting to 3.5. However, you can do side by side upgrade since it's possible to run both VS 2003 and VS 2008 on the same machine.

bes1124
bes1124

It takes more time/effort to migrate from 1.1 to 2.0... the process is much more invasive. One "cook-book" web site has instructions for the migration that is about six printed pages long. Bruce