I´m declaring MidasLib to avoid dll hell caused by Midas.dll in some clients.
The code below runs in about 2350ms. If I remove the MidaLib declaration in uses it starts to run in just 45ms!!
The data.xml file was saved with TClientDataSet.SaveToFile method, has 5000 records and its size is about 600Kb.
Does anybody knows how to explain this weird behavior?
I can confirm the problem in Delphi XE2 upd 3 and in Delphi XE3 upd 2.
Thanks.
program Loader;
{$APPTYPE CONSOLE}
{$R *.res}
uses
MidasLib,
System.SysUtils,
Winapi.Windows,
Data.DB,
Datasnap.DBClient;
var
cds : TClientDataSet;
start, stop : Cardinal;
begin
cds := TClientDataSet.Create(nil);
try
start := GetTickCount;
cds.LoadFromFile('c:\temp\data.xml');
stop := GetTickCount;
Writeln(Format('Time elapsed: %dms', [stop-start]));
finally
cds.Free;
end;
end.
It is a known bug/regression, see the QC reports
We just use local copy of Midas DLL regardless of what is installed in the system, and only falling back to global one, if local one is not found.
We use XE2 upd4 hf1 and we later switched to Midas DLL of XE4 ( main project still is made with xe2 )
I'm not sure why you think you need to use MidasLib to "avoid DLL hell".
When the RTL calls
TCustomClientDataSet.CreateDSBase
, this callsCheckDbClient
in DSIntf.Pas. It is this routine which determines which instance of Midas.Dll is loaded, by examining the registry.So, you could ensure that a particular instance of Midas.Dll is used by ensuring that the registry reflects its location before
CheckDbClient
is called. The registry setting isInProcServer32
underHK_Classes_Root\CLSId\{9E8D2FA1-591C-11D0-BF52-0020AF32BD64}
. It can be updated by callingRegisterComServer
specifying the Midas path and filename, subject to necessary registry access permissions, of course.