Discussion:
CoInitialize has not been called
(too old to reply)
Mohammad
2008-06-11 05:12:27 UTC
Permalink
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?
Bob Swart
2008-06-11 06:04:38 UTC
Permalink
Hi Mohammad,
Post by 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
--
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: http://stores.lulu.com/drbob42
Personal courseware + e-mail support http://www.ebob42.com/courseware
Blog: http://www.drbob42.com/blog - RSS: http://eBob42.com/weblog.xml
Mohammad
2008-06-11 12:32:05 UTC
Permalink
thanks Bob.
Post by Bob Swart
Hi Mohammad,
Post by 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
Loading...