Post NET 2.0 Migration Wizard steps
Migration to NET 2.0 Adventures
Changed Strong Name configuration
The attributes AssemblyKeyFile and
AssemblyDelaySign that previously existed in the
AssemblyInfo.cs file are not longer supported.
The recommended way to specify a strong name is by
using the “Signing” tab in project properties. So,
you must eliminate these unwanted attributes from
every AssemblyInfo.cs file and touch every project
configuration manually.
I think that simple and mechanical task could be
performed by the conversion wizard, don’t you?
DNS (System.Net)
All “GetHostXXX” and “Resolve” functions are now
replaced by the all powerful GetHostEntry. They
return the same IPHostEntry objects and the change
is rather simple.
GetHostByName à
GetHostEntry
GetHostByAddress à
GetHostEntry
Resolve à
GetHostEntry
MessageQueue (System.Messaging)
The method “GetMessageEnumerator” is now obsolete,
replace with “GetMessageEnumerator2” without further
changes.
Configuration (System.Configuration)
The exception “ConfigurationException” is now
obsolete, and is recommended to use the new
“ConfigurationErrorsException” exception.
Remember to add a reference to the
“System.Configuration” assembly or the later won’t
be found.
Replace the class “ConfigurationSettings” by
“ConfigurationManager”.
The method “GetConfig” from class
“ConfigurationSettings” is now replaced by the
method “GetSection” in the “ConfigurationManager”
class.
Diagnostics (System.Diagnostics)
If your application writes to the EventLog you
should be doing a security assert trough CAS. The
recommended way to do that is using declarative
security through the use of attributes, in
particular “EventLogPermissionAccessAttribute”.
Previously, if you wanted full access to the
EventLog you should demand “Instrument” permission.
This permission is now deprecated and you should use
“Write” permission.
EventLogPermissionAccess.Instrument à
EventLogPermissionAccess.Write
Permissions (System.Security)
If your application writes to the registry you
should be doing a security assert trough CAS. The
recommended way to do that is using declarative
security through the use of attributes, in
particular “RegistryPermissionAttribute”.
Previously, if you wanted full access to the local
registry you should demand “All” permission. This
permission is now deprecated and you should use
“ViewAndModify” permission.
RegistryPermissionAttribute.All à
RegistryPermissionAttribute.ViewAndModify
The property “FullTrustAssemblies” in the class
“PolicyLevel” is no longer supported. All references
to this must be removed from the project.
InteropServices (Microsoft.Win32)
If you use interop you must work with handles. In
NET 1.1 existed the “WaitHandle” class for thread
synchronization but for NET 2.0 has been superseded
by the new “SafeWaitHandle”. The change is almost a
search & replace operation.
WaitHandle à
SafeWaitHandle
Collections (System.Collections)
The model for IDictionary based collections changed
in the way internal items are compared and stored
through the use of Hash codes. So, all constructors
using an ICompare and IHashCodeProvider are now
obsolete and should be replaced by the new
IEqualityComparer interface.
In our case, the keys of all collections are
strings and case insensitive so we use the
“StringComparer.InvariantCultureIgnoreCase”
object.
ICompare, IHashCodeProvider à
StringComparer.InvariantCulture
ICompare, IHashCodeProvider à
StringComparer.InvariantCultureIgnoreCase
All Framework classes implementing IDictionary must
be changed to reflect the new signatures. Some of
the more important classes modified include:
CacheHelper.cs, IndexedDictionary.cs and
XmlSerializableDictionary.cs.
General
All ToString( CultureInfo.InvariantCulture ) is now
obsolete and the “CultureInfo” object must be
removed from the “ToString” function.
Remoting
The method “RegisterChannel” from the class
“RemotingServices” now requires an additional
Boolean parameter “security” to indicate if this
channel will have security restrictions enabled.
This flag supersedes the previous configuration
parameter “typeFilterLevel=Full” to allow
serialization of unsafe Types.
The “Configure” method from class
“RemotingConfiguration” now requires an additional
Boolean parameter “security” to indicate if security
restrictions are enabled. This flag supersedes the
previous configuration parameter
“typeFilterLevel=Full” to allow serialization of
unsafe Types.
Reflection
The “AppDomain” class no longer supports the method
“AppendPrivatePath”. To change this configuration
the property “PrivatePathBin” from the
“SetupInformation” property must be appended with
the new folders, separated by semicolon.
The “AppDomain” class no longer supports the method
“SetShadowCopyPath”. To change this configuration
the property “ShadowCopyDirectories” from the
“SetupInformation” property must be appended with
the new folders, separated by semicolon.
The function “LoadWithPartialName” from the
“Assembly” class is not longer supported and must be
replaced by the “Load” method.
ASP.NET
Pages containing a control named “Header” will fail
to compile because the new “Page” class already
includes a new “Header” property. The controls are
renamed “HeaderLabel” to avoid the conflict.
The methods “IsClientScriptBlockRegistered” and
“RegisterClientScriptBlock” are now obsolete in the
“Page” object and the “ClientScript” class must be
used.
XML
The class “XslTransform” is now obsolete and
replaced by the new “XslCompiledTransform”. This new
class has some new overloads for the method
“Transform” but in general conversion is easy.
The method “ToDateTime” from the class “XmlConvert”
has a new parameter indicating the serialization
mode of the date value. This new parameter is an
enum of type “XmlDateTimeSerializationMode” and
defines if the DateTime will be serialized using
local time, UTC, etc.
The class “XmlSchemaElement” no defines a strong
typed “ElementSchemaType” property that replaces the
old (no strong typed) “ElementType”.
The class “XmlValidatingReader” is not longer
supported, so “XmlReader” must be used. The class
“XmlReader” now uses a new class of type
“XmlReaderSettings” to configure the type of
validation to use and schema information to include.
This class is passed to the constructor of the new
“XmlReader” class.
Threading
The “ApartmentState” property in the “Thread” class
is now obsolete and must be replaced by
“GetApartmentState” and “SetApartmentState” methods.
Change is a simple copy & paste operation.
The property “GetCurrentThreadId” in the
“AppDomain” class is now obsolete and must be
replaced by the property “ManagedThreadId” in the
“Thread” class.
Best Regards,
Andrés G Vettori
MCSE/MCSD/MCT
Leader
of the C# Community of the Microsoft Users Group Argentina
3 Comments
Comments have been disabled for this content.
Vishal said
Hi Andrew! You have come up with really good list migration item list here. I am sure it will be v.helpful. Was wondering if you could answer a problem we are facing. After running the conversion wizard we are not able to open .Net 1.x forms in VS 2005's Design mode. Any ideas?
Nams said
I am gonna start with migration - guess, this is gonna be of real help - thanks Plz do update more changes. We are eagerly waiting. . .
Shahaji Udar said
Really helpful article!!!