Monday, May 31, 2010

[Tutorial] Migration to Framework .NET 4.0 & Visual Studio 2010
Part4: Obsolete Types and Members

The last article concerned migration issues and their possible solutions. This part of the series talks about obsolete functionality in the latest version of the .NET Framework and what happens if you still need to use those functionalities.

Usage of obsolete types and members

Each new .NET Framework version adds new types and members that provide new functionality. Existing types and members change. Sometimes types are replaced because the technology that they where used for was deprecated. In other cases new types and members are more complete and easier to use.

To assure the highest possible compatibility with preceding versions, those obsolete types and members are not directly deleted. Instead they are marked as obsolete using the attribute “ObsoleteAttribute”. They still work even in the latest .NET Framework versions.

If code that is using obsolete types or members is recompiled, the compiler might raise warnings or in some cases even errors (which must be modified). Code that was compiled with an old version of the compiler and that uses obsolete types and members will however always execute correctly, even after the migration to the .NET 4.0 Framework.

Obsolete Types

  • All types that reside in the System.Data.OracleClient namespace are deprecated. You should use the Oracle specific provider within ODP.NET.

  • Passport authentification is not supported anymore, you should use the LiveID instead. All associated types are obsolete.

  • All types in System.Web.Mail should not be used anymore, instead you should use those within the System.Net.Mail namespace.

  • The System.Web.Mobile.dll assembly that was used for mobile development is deprecated.

  • XmlDataDocument and XslTransform are deprecated, you should use XslCompiledTransform instead.

Obsolete Members

  • Some methods in LINQ needed to be modified for the implementation of PLINQ (parallel processing within LINQ)

  • Concerning the Entity Framework, the ApplyPropertyChanges function is replaced by the ApplyCurrentValues function and the SaveChanges function expects an enumeration as parameter instead of a Boolean value

  • Multiple methods within System.Diagnostics.Process are replaced by their equivalents in 64 bits

  • Members that were already obsolete since .NET Framework 2.0 still exist. They were not yet deleted (but should should not use them anymore in your developments).

Additional Information in MSDN

For further information on this subject and much more obsolete types and members, please visit Microsofts MSDN site: 
http://msdn.microsoft.com/en-us/library/ee461503%28v=VS.100%29.aspx
http://msdn.microsoft.com/en-us/library/ee471421%28v=VS.100%29.aspx


Share/Save/Bookmark

Sunday, May 30, 2010

[Tutorial] Migration to Framework .NET 4.0 & Visual Studio 2010
Part3: Migration Issues and their Solutions

The last part of the series showed the Visual Studio 2010 Conversion Wizard. This part explains what needs to be done in case of migration issues.

Most of the changes in .NET 4.0 do not require any code modifications. But sometimes you will encounter problems and that is where you will need to apply some workaround solutions. I am going to show you some examples of these solutions in this article.

Core

Access to configuration files was modified. If your configuration file is named “MyApplication.config” you will have to rename it to “MyApplication.exe.config”.

ASP.NET

When using the Conversion Wizard within Visual Studio 2010 to convert your ASP.NET 3.5 applications to ASP.NET 4.0, the Web.config file is also modified in the process. It contains new parameters that might not be exactly configured as you like it.

  • The display mode of some controls was modified. To deactivate this new display mode change the following parameter:
    <pages controlRenderingCompatibilityVersion="3.5" />

  • The validation mode of HTTP requests was ameliorated (cross-site scripting protection). To reestablish the preceding behavior add the following parameter:
    <httpRuntime requestValidationMode="2.0" />

  • The UrlEncode and HtmlEncode methods were modified. Please verify that they work as expected.

  • The page parser for ASPX and ASCX is stricter than before. You should fix any invalid markup.

Windows Presentation Foundation (WPF)

The XAML parsing was modified. XAML attributes cannot contain more than one period anymore.

The following are valid examples after the migration:
<button Background="Red"/>
<button Button.Background="Red"/>

The following is not accepted anymore after the migration:
<button Control.Button.Background="Red"/>

Additional Information in MSDN

For further information on this subject and much more workaround solutions, please visit Microsofts MSDN site:  http://msdn.microsoft.com/en-us/library/ee941656%28v=VS.100%29.aspx


Share/Save/Bookmark

Wednesday, May 26, 2010

[Tutorial] Migration to Framework .NET 4.0 & Visual Studio 2010
Part2: Conversion Wizard Visual Studio 2010

The last article showed basics on how to migrate to Framework .NET 4.0. This article shows the Conversion Wizard of Visual Studio 2010.

Conversion Wizard Visual Studio 2010

Visual Studio 2010 provides a Conversion Wizard that helps converting old projects and solutions to the new Visual Studio 2010 format (similar to the conversion wizard within Visual Studio 2008 ).

VS_Conversion_Wizard1VS_Conversion_Wizard2 VS_Conversion_Wizard3 VS_Conversion_Wizard4

The converted projects and solutions replace the existing ones so take care to do some backups before the migration.

If projects cannot be converted, they are marked as unavailable in the Solution Explorer until the problems are resolved and they are correctly converted.

To migrate multiple projects or solutions it is possible to create batch files and execute the migrations in batch mode.


Share/Save/Bookmark

[Tutorial] Migration to Framework .NET 4.0 & Visual Studio 2010
Part1: Version Compatibility and Simple Migration

The new version of .NET Framework 4.0 was released last month together with Visual Studio 2010. An important question is how to migrate existing applications. This series of articles provides information on how to proceed and what you can expect when doing the migration.

Version Compatibility

In most cases the .NET 4.0 Framework is fully compatible with applications that were developed using past versions of the .NET Framework (1.1, 2.0, 3.0, 3.5).

Version Compatibility assures that an application that was developed using a past version of .NET should also work on a more current version. Moreover, source code that was written using an old version should also compile on the current version.

Simple migration

After installing the new Framework version, the old assemblies do not need to be  recompiled. Instead you may execute old and new assemblies Side-By-Side (SxS). It is now possible to to have different versions of the CLR running in the same application and they can even communicate with each other.

If you need to force the usage of CLR 4.0, you only need to add an application configuration file that contains the version specifications. You do this by specifying one or multiple  <supportedRuntime version="vX.X" /> elements (the first being your preferred version).

The following values are currently possible:

Framework .NET Version

Version String

4

v4.0

3.5

v2.0.50727

2.0

v2.0.50727

1.1

v1.1.4322

1.0

v1.0.3705

Example of a configuration file for .NET 4.0:

examplefile

If you need to migrate a large amount of applications it makes more sense to do the migration on machine level. There is the registry key “OnlyUseLatestCLR” that serves for this purpose.

  • Open a registry editor (example: regedit.exe)
  • Go to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
    .NETFramework]
  • Set the value of OnlyUseLatestCLR=dword:00000001
  • For 64 bit systems you also need to set the key within [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NET Framework]

To deactivate la functionality, you only need to reset the value of the key to OnlyUseLatestCLR=dword:00000000.


Share/Save/Bookmark

Tuesday, May 4, 2010

[Publication] Article in French Programmez Magazine on .NET Framework 4.0 migration

You can find an article of 3 pages concerning .NET Framework 4.0 migration in the French Programmez magazine No.130 written by me and a colleague.

cover

First Page (low resolution)

Second and third page (low resolution)

The article is written in French but I plan to write some English articles on my Blog in the next weeks. So stay tuned if you are interested in knowing how to proceed when migrating your .NET applications (1.1, 2.0, 3.5) to the latest .NET Framework version!


Share/Save/Bookmark