We have a current product written in Delphi 6 websnap, which I’m attempting to upgrade to run under delphi 2005.
It uses ADO, and the error on running is “CoInitialize has not been called”.
The only references I can find to this error point to IntraWeb and something called ServerController, which I’m not sure is relevant to me.
Any number of calls of CoInitialize(nil) have no effect.
Am I wasting my time getting this to run or is it possible to run under 2005 -or a later release come to that?
CoInitializeneeds to be called within the thread that does the COM access (e.g. in any thread that accesses your database through ADO). It is called in the main thread by Delphi by default, but you need to call it explicitly in other threads.Try calling it in the
OnActivateevent, and callCoUninitializein theOnDeactivateevent.Also make sure your ADOTables and ADOConnections are not open at design time. As otherwise the app will try to use COM before you’ve called
CoInitialize.If all else fails – try overriding the web form’s constructor and slip a
CoInitializein there before you call inherited. Don’t forget to callCoUninitializein the destructor.