UniDac to XData Server from Web Client

Hi,


Anyone have a working copy of using UniDac connection and XData Server as server and then successfully accessing it from a Web Core client application?

I get the following error when I run it:
Project xxx.exe raised exception class EOLEDBError with message 'OLE DB error occurred. Code 800401F0h. CoInitialize has not been called.'

Regards,
Johan
You must call 

  CoInitializeEx(nil, COINIT_MULTITHREADED);

to initialize the COM library that will be used by the db access component. 
The best place is to use a middleware so you are sure all threads will have it called. You can do that using the TXDataServer.OnModuleCreate event:

procedure TDataModule2.XDataServer1ModuleCreate(Sender: TObject;
  Module: TXDataServerModule);
begin
  Module.AddMiddleware(TAnonymousMiddleware.Create(
    procedure(Context: THttpServerContext; Next: THttpServerProc)
    begin
      CoInitializeEx(nil, COINIT_MULTITHREADED);
      try
        Next(Context);
      finally
        CoUninitialize;
      end;
    end
  ));
end;

Thanks Wagner,


This worked!

For clarity the uses clause:
uses
  ..
  ActiveX;

Regards,
Johan