I have Remobjects_OpenXML defined for my client project which is working well and I do not use the uROComInit unit.
I’ve recently tried to convert opening some TDaMemDataTables in a thread using TTask.Run().
Sample code:
procedure TPatientData.OpenAsync;
begin
TTask.Run(
procedure
begin
tbl_Patients.Open; // beforeOpen sets DynamicWhere clause
tbl_SomeOtherTable.Open;
TThread.Synchronize(nil,
procedure
begin
if assigned(AfterOpen) then
AfterOpen(tbl_Patients); // will call back to the calling UI form
end
);
end
);
end;
The table(s) being opened are always on their own TDataModule which has it’s own Channel & Message components (as well as Bin2DataStreamer and RemoteDataAdapter).
In creating each datamodule instance I set the URL of the Channel and the ClientID of the Message from the main Channel and Message components on my ClientDataModule – so I think I’m right in saying this should make it safe to open the table(s) in a thread.
My problem is that I’ve noticed that I’m getting “CoIniitalize has not been called” errors when trying to open these tables in a thread, even though I have RemObjects_OpenXML defined.
I’ve temporarily solved the issue by wrapping the .open calls in CoInitialize/CoUninitialize calls but I’d like to be able to use these business data objects in non-Windows platforms.
How can I fix that so that I don’t need to use CoInitialize or winapi.activex ?
If I carry on through the exceptions, I get to this one also:
Exception class EROException with message
‘Error creating MSXML Document classEOleSysError: CoInitialize has not been called, ClassID: {88D96A05-F192-11D4-A65F-0040963251E5}’.
If I don’t define RemObjects_OpenXML then should the I use the unit uROInitializedThread, or should I use uROComInit and call CoInitialize/CoUnInitialize in threads (i.e. TTask.Run()) ?
ROInitializedThread unit is a workaround when uROComInit cannot be used at all.
for example, std Open/SaveDialogs work incorrectly if uROComInit is used…
I’m still hitting an issue with this. I have uROInitializedThread in the project source (second below FastMM4).
I am setting uROInitializedThread.ROInitializeThreads := TRUE as the first line of project source in the DPR.
I am using TTask.Run() to start a process that eventually opens a TDAMemDataTable on a datamodule - and this is still giving me “CoInitialize has not been called” errors when it tries to open the table.
Should I be getting this error or have I misunderstood?
The TDAMemDataTable is on a DataModule that may, or may not, be opened in a thread.