Andru's WebLog

//Comments about technology and software architecture
>MySelf.Persist();

December 2005 - Posts

Post NET 2.0 Migration Wizard steps

Migration to NET 2.0 Adventures

Well, I have started the migration of our huge code base to NET 2.0. Our entire solution includes more than 30 C# projects (counting setup projects), so it's a rather big solution.

 

I opened the VS2003 root solution using VS2005 to kick off the conversion process, and in general all went smooth. The process finished without problems after serveral minutes of hard work, everything compiled without major issues and then the post-convert tasks begin.

 

We have a policy regarding compiler warnings that states that all warnings must be treated as errors, so I must fix all warnings before continue. Several things are changed to obsolete in NET 2.0, and here I present a condensed list of items fixed to avoid those "obsolete" compiler warnings.

 

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.

 

  

I hope this serves as a guide for anyone migrating a NET 1.1 project to 2.0. I will post more information as the process of migration moves forward.

Best Regards,

Andrés G Vettori
MCSE/MCSD/MCT
Leader of the C# Community of the
Microsoft Users Group Argentina

 

 

Posted: Dec 13 2005, 04:26 PM by andresv | with 3 comment(s)
Filed under:
Team Foundation Server setup problems and ConfigureNTLM

Well, I finally managed to install it...   but it wasn't easy....

The server I installed has W2K3 with a couple of instances of SQL 2000, IIS and a lot of other crap and old things no longer used. So, my first task was to make some cleanup.

I uninstalled almost everything, installed W2K3 SP1, Windows Update, Reboot, Defrag all disks.

After reading all installation documentation, I begin Team Foundation installation. First I installed SQL 2005 Standard Edition, then Sharepoint Services using the silent setup command found in the documentation, and all went smooth.

Finally, I started the Team Foundation setup, but...   there are allways a but....   here is where things go wrong. The setup failed and showed a little dialog saying something about a command named "ConfigureNTLM.exe" that failed execution. Damm!

Well, to make a long story short, after searching on the NET and found nothing related with this specific error applied to my conditions (there is a possibility that this error also accurs if port 8080 is in use before Team Foundation Setup, because the web site that is configured try to use this port), and then I uninstalled and reinstalled all a couple of times with the same result.

So, I found myself reading all installation logs to try to understand what happened....  and I found the culprit!

The setup try to configure the Team Foundation site to use NTLM as authentication, and also tries to configure the compression filters for the site. In a clean IIS environment this wouldn't be a problem, but in this particulary server (for whatever reason I don't know or can explain) the default compression filters aren't present. I think that the most likely cause for something as bizarre as this happens is metabase corruption, but I'm open to suggestions/comments here...

The solution?  There are two solutions for this.

The easy one: Uninstall IIS (and Sharepoint, and SQL, and Reporting Services, etc, etc)

The risky one: Touching the metabase by hand to manually add the missing filter configuration.

Well, I give a shot at the risky solution, and it worked like a charm!

After that, setup went smooth....  and I go home after another fun day...

The story here: if you have the "32000 - ConfigureNTLM" error, you can be sure it's IIS related. Check the 8080 port is not in use, and if not....   probably is better to reinstall the whole thing. The documentation states clearly that a clean server is a prerequisite....  so it must be true, don't you think?

Best Regards,

Andrés G Vettori
MCSE/MCSD/MCT
Leader of the C# Community of the
Microsoft Users Group Argentina

Posted: Dec 07 2005, 11:20 AM by andresv | with no comments
Filed under:
Retina.NET v1.0.7 Prerelease Published

I'm just uploaded to the Retina Workspace at GotDotNet a prerelease version of Retina.NET v1.0.7 (build 2) for testing and feedback from the community.

It's a source only release, and although the core of Retina.NET is finished, I still have to work some more in some DataProviders, samples and documentation. DataProviders MSSQL, MSSQL2005 and SharpHsql are complete and ready for you to test and use. Other DataProviders lacks Criteria Paging and version control features that will be implemented shortly.

The assemblies now use "Delay Sign" for their strong name, and because the sources do not include the private key you must use the included "snoverify.reg" to skip verification of assemblies partially signed.

For a list of new features and changes please look at "changes.txt" file.

There might be some uncovered bugs yet in the Core (this version includes HUGE features) and the idea is to find them before the final release.

Retina.NET v1.0.7 will be the last NET 1.1 release as I'm already working on a NET 2.0 version.
Anybody wanting to collaborate on docs/samples/etc will be welcome, and maybe we can release the final version sooner than expected.

Best Regards,

Andrés G Vettori
MCSE/MCSD/MCT
Leader of the C# Community of the
Microsoft Users Group Argentina

Posted: Dec 04 2005, 03:30 PM by andresv | with 3 comment(s)
Filed under: ,
SharpHsql 1.0.3.3 Released

This is a minor release made to support all the new features of the Retina.NET ORM v1.0.0.7, and the changes are:

*- Better support for output parameters in the ADO.NET provider.
*- Support for TIMESTAMP columns.
*- Better support for variables and their assignation of values.
*- Removed the SQL Mobile dependency from the PocketPC version.
*- Some other minor issues.

You can download SharpHsql source and binaries from http://workspaces.gotdotnet.com/sharphsql

Best regards,

Andrés G Vettori
MCSE/MCSD/MCT
Leader of the C# Community of the
Microsoft Users Group Argentina

Posted: Dec 04 2005, 02:07 PM by andresv | with 1 comment(s)
Filed under:
More Posts