Board index » delphi » CoInitialize has not been called

CoInitialize has not been called


2008-06-11 01:12:27 PM
delphi128
Hi,
I have use an ADOConnection in my IntraWeb program and put it in
IWUserSession(UserSessionUnit) unit.
when I set Connected to True exception "CoInitialize has not been
called" raised(I have written CoInitialize(nil) and CoUnInitialize in
OnNewSession and OnDestroy).
Can someone tell me what am I doing wrong?
 
 

Re:CoInitialize has not been called

Hi Mohammad,
Quote
I have use an ADOConnection in my IntraWeb program and put it in
IWUserSession(UserSessionUnit) unit.
when I set Connected to True exception "CoInitialize has not been
called" raised(I have written CoInitialize(nil) and CoUnInitialize in
OnNewSession and OnDestroy).
Instead of calling CoInitialize yourself, you should take a look at the
ComInitialization property of the server controller.
From my IntraWeb courseware manual: "The ComInitialization property of
type TComInitialization (ciNone, ciNormal, ciMultiThread) is needed when
the application requires the use of (D)COM. Since IntraWeb executes
requests in different threads, each thread must make its own call to
CoInitialize.
By default this property is set to ciNone, to indicate that no COM
support is required. If you need COM support - for example if you want
to connect to a DataSnap server - then you need to set ComInitialization
to ciNormal or ciMultiThreaded.
Personally, Iíve found no reason not to set it to ciMultiThreaded when
working with COM in one way or another inside an ISAPI DLL."
Groetjes,
Bob Swart
--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
CodeGear Technology Partner -- CodeGear RAD Studio Reseller (BeNeLux)
Delphi Win32 & .NET books on Lulu.com: stores.lulu.com/drbob42
Personal courseware + e-mail support www.ebob42.com/courseware
Blog: www.drbob42.com/blog - RSS: eBob42.com/weblog.xml
 

Re:CoInitialize has not been called

thanks Bob.
Bob Swart writes:
Quote
Hi Mohammad,

>I have use an ADOConnection in my IntraWeb program and put it in
>IWUserSession(UserSessionUnit) unit.
>when I set Connected to True exception "CoInitialize has not been
>called" raised(I have written CoInitialize(nil) and CoUnInitialize in
>OnNewSession and OnDestroy).

Instead of calling CoInitialize yourself, you should take a look at the
ComInitialization property of the server controller.

From my IntraWeb courseware manual: "The ComInitialization property of
type TComInitialization (ciNone, ciNormal, ciMultiThread) is needed when
the application requires the use of (D)COM. Since IntraWeb executes
requests in different threads, each thread must make its own call to
CoInitialize.
By default this property is set to ciNone, to indicate that no COM
support is required. If you need COM support - for example if you want
to connect to a DataSnap server - then you need to set ComInitialization
to ciNormal or ciMultiThreaded.
Personally, Iíve found no reason not to set it to ciMultiThreaded when
working with COM in one way or another inside an ISAPI DLL."

Groetjes,
Bob Swart