Migrating Legacy (DCOM based) DataSnap Servers from Delphi 2007 (and earlier) to Delphi 2009/2010 (and later)

by Mar 24, 2016

A DataSnap migration question came up in today's webinar, “Delphi 2007 to Delphi 10 Seattle Migration: Easy!". Miguel Angel Moreno asked “Is there any webinar/document covering an easy way to convert old Midas remote provider based applications to the new DataSnap 2009 Rest remote dataset based approach? This is about one of the hardest functionalities to convert/migrate in old Delphi/C++Builder applications.” Here are four resources that will help you migrate your legacy DCOM based DataSnap servers to Delphi 2009/2010 all the way up to Delphi 10 Seattle.

1. Bob Swart’s “Delphi 2009 Development Essentials book”

DataSnap chapter by Dan Miser covers the topic “Reusing Existing [DataSnap] Remote Data Modules”


[Note: David I. text copied/edited from newsgroup post from Bob Swart to Jon Robertson to help in preparation for his CodeRage 5 presentation/demonstration]

If you have existing TRemoteDataModule classes, then you can still use these in combination with DataSnap 2009/2010. But you have to cut some functionality from the server, especially the COM-stuff.
First of all, if it’s an existing DataSnap Server application that you want to migrate, and not just the remote data module, you need to unregister the DataSnap server by running the executable from the command-line with the /unregister command-line option. If you don’t do that right from the start, you will not be able to unregister the remote data module from the registry (unless you can restore a backup of the project later).
In the unit for the remote data module, we must remove the code from the initialization section. If you want to keep your unit compatible between Delphi 2007 and 2009/2010, you can place this code inside {$IFDEF}s as follows:

{$IF CompilerVersion <= 20}


   TComponentFactory.Create(ComServer, TMyRemoteDataModule,

     Class_MyRemoteDataModule, ciMultiInstance, tmApartment);



You should also remove the UpdateRegistry routine from the project, or place it in {$IFDEF}s as well.

{$IF CompilerVersion <= 20}

   class procedure UpdateRegistry(Register: Boolean;

     const ClassID, ProgID: string); override;


The most important change – to turn the project into a COM-less DataSnap Server – involves the removal of the type library (or .ridl files) and the type library import unit.
These cannot be left in {IFDEF}s, so if you need to keep a Delphi 2007 (COM-enabled) and Delphi 2009/2010 (COM-less) version of the DataSnap server you need to make a copy of the project now. We should use a TDSServerClass component in the DataSnap server application and return the TRemoteDataModule class, just as we have done before.
Finally, we should make sure that all custom methods that were added to the TRemoteDataModule are moved from the protected section (the default in COM-enabled DataSnap) to the public section (so method info is generated in the COM-less DataSnap architecture).
2. Migrating Delphi DCOM DataSnap Projects to Delphi 2009 DataSnap
Jon Robertson – jmrSoftware
CodeRage 5 Video Replay
Friday, October 8, 2010 at 7am

Learn some of the challenges and solutions of migrating mature DCOM DataSnap servers to the new Delphi 2009 DataSnap architecture.

3. White Paper: The New DataSnap in Delphi 2009 by Marco Cantu
For a long time Delphi has included a technology for building multi-tier database applications. Formerly known as MIDAS and later as DataSnap, Delphi's multi-tier technology was based on COM, even if the remote connectivity could be provided by sockets and HTTP, instead of DCOM. For some time, it even supported CORBA–a slightly modified version that provided SOAP connectivity. Delphi 2009 still includes the classic DataSnap, but provides a new remoting and multi-tier technology as well. It is partially based on the dbExpress architecture. This new technology is still called DataSnap, but to avoid confusion is generally referenced as “DataSnap 2009”.

4. DataSnap 2009 Overview

By Steven Shaughnessy


Developer Network article with an overview of the new capabilities in DataSnap 2009 including the move from DCOM based Remote Data Modules.