delphi – How to embed the MIDAS.DLL in the client executable – Stack Overflow
Posted by jpluimers on 2021/08/17
I hardly use the [WayBack] TClientDataSet
Class any more, so every once in a while I bump into a legacy project that does.
Often that forgets provide a deployment list, so usually with deployment of the underlying DLL is forgotten.
Those moments, it slips my mind that the original name for the underlying DataSnap technology is called MIDAS, and the DLL is MIDAS.DLL. Sometimes even a wrong version of that DLL is distributed (unicode versus non-unicode still can still be a thing).
You can avoid loading it (often at a premium of reduced speed) my adding MidasLib to the uses list of any unit in your project:
- [WayBack] delphi – How to embed the MIDAS.DLL in the client executable – Stack Overflow
you add
MidasLib
to your project’s USES clause. This embeds the basic functionality into your program without having to rely on a separate DLL for it. - [WayBack] Deploying Applications that use ClientDataSets
- [WayBack] delphi – MidasLib.dcu makes the application slower – Stack Overflow
- WayBack: QualityCentral Report # 109476 [Regression in XE2] With MidasLib unit static linking, TClientDataSet loading XML large file takes long time
- WayBack: QualityCentral Report # 107346 Status: Open [x64] TClientDataSet.LoadFromFile slow in 64-bit app
When you use BPLs instead of full units, then missing this can lead to a nasty access violation like this one where the ClientDataSet cannot be created because the wrong Midas.dll (non-unicode) was loaded, see the screenshot and stack overflow below.
Lessons re-learned:
- Use a minimal deployment footprint
- Ensure your test systems are clean, so no older versions of dependencies can be loaded at any time.
OS EAccessViolation at adress 5110E007: Access violation at address 5110E007 in module 'dsnap250.bpl'. Read of address 00000000 {occured in main thread} Stack: [50060B13]{rtl250.bpl } System.@HandleAnyException [00404815]{GVS.exe } FastMM4.CalculateHeaderCheckSum$qqrp29Fastmm4.TFullDebugBlockHeader (Line 9098, "FastMM4.pas" + 1) [50060039]{rtl250.bpl } System.@AfterConstruction [00404815]{GVS.exe } FastMM4.CalculateHeaderCheckSum$qqrp29Fastmm4.TFullDebugBlockHeader (Line 9098, "FastMM4.pas" + 1) [00404824]{GVS.exe } FastMM4.UpdateHeaderAndFooterCheckSums$qqrp29Fastmm4.TFullDebugBlockHeader (Line 9108, "FastMM4.pas" + 1) [004057C6]{GVS.exe } FastMM4.DebugGetMem$qqri (Line 9649, "FastMM4.pas" + 42) [00405817]{GVS.exe } FastMM4.DebugGetMem$qqri (Line 9686, "FastMM4.pas" + 79) [5005A247]{rtl250.bpl } System.@ReallocMem [50065674]{rtl250.bpl } System.DynArraySetLength [50065715]{rtl250.bpl } System.@DynArraySetLength [5110D001]{dsnap250.bpl} Datasnap.Dbclient.TCustomClientDataSet.CreateDSBase [51111571]{dsnap250.bpl} Datasnap.Dbclient.TCustomClientDataSet.CreateDataSet [500E920D]{rtl250.bpl } System.Rtti.TValue._op_Implicit [00559D29]{CDSDemo.exe } MainDataModuleUnit.TMainDataModule.DataModuleCreate (Line 50, "MainDataModuleUnit.pas" + 1) [5016E7EF]{rtl250.bpl } System.Classes.TDataModule.DoCreate [5016E69C]{rtl250.bpl } System.Classes.TDataModule.AfterConstruction [50060039]{rtl250.bpl } System.@AfterConstruction [5016E67A]{rtl250.bpl } System.Classes.TDataModule [00544941]{CDSDemo.exe } MainFormUnit.TMainForm.PageControlChange (Line 30, "MainFormUnit.pas" + 19) [0054598B]{CDSDemo.exe } MainFormUnit.TMainForm.FormShow (Line 40, "MainFormUnit.pas" + 47) [50C075DD]{vcl250.bpl } Vcl.Forms.TCustomForm.DoShow [50C0BF7D]{vcl250.bpl } Vcl.Forms.TCustomForm.CMShowingChanged [5005FD9F]{rtl250.bpl } System.TObject.Dispatch [50AC4C16]{vcl250.bpl } Vcl.Controls.TControl.WndProc [50AC97FB]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc [50C080B5]{vcl250.bpl } Vcl.Forms.TCustomForm.WndProc [50AC4850]{vcl250.bpl } Vcl.Controls.TControl.Perform [50AC8B71]{vcl250.bpl } Vcl.Controls.TWinControl.UpdateShowing [50AC8C80]{vcl250.bpl } Vcl.Controls.TWinControl.UpdateControlState [50ACB9D6]{vcl250.bpl } Vcl.Controls.TWinControl.CMVisibleChanged [50AC4C16]{vcl250.bpl } Vcl.Controls.TControl.WndProc [50AC97FB]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc [50C080B5]{vcl250.bpl } Vcl.Forms.TCustomForm.WndProc [50C0E597]{vcl250.bpl } Vcl.Forms.TScreen.GetMonitor [50C094C5]{vcl250.bpl } Vcl.Forms.TCustomForm.SetWindowToMonitor [50AC4850]{vcl250.bpl } Vcl.Controls.TControl.Perform [50AC31E6]{vcl250.bpl } Vcl.Controls.TControl.SetVisible [50C078C1]{vcl250.bpl } Vcl.Forms.TCustomForm.SetVisible [50C11DCF]{vcl250.bpl } Vcl.Forms.TApplication.Run [004B3B28]{CDSDemo.exe } VclApplication.TApplication.Run (Line 113, "VclApplication.pas" + 1) (00161097){CDSDemo.exe } [00562097]
–jeroen
Leave a comment