deadlock 
Author Message
 deadlock

Hello,
I have a project(service) that includes 2 Objects :
ObjectA, Object B with apartment threading model.
A method of ObjectA must create an instance of Object B, so I call:

CComPtr<IObjectB> m_objB
m_objB.CoCreateInstance(CLSID_ObjectB,NULL, CLSCTX_LOCAL_SERVER);

This causes a deadlock.
I'm trying to understand what am i doing and how should i do it right, but
please, if you can give me a clue.

Thanks for your help
Andrea



Thu, 24 Feb 2005 02:18:35 GMT  
 deadlock
I hope you may find an answer to your problem
in MSDN "Dr GUI #45" article titled

"Getting Smart with COM"

regds
Del.


Quote:
> Hello,
> I have a project(service) that includes 2 Objects :
> ObjectA, Object B with apartment threading model.
> A method of ObjectA must create an instance of Object B, so I call:

> CComPtr<IObjectB> m_objB
> m_objB.CoCreateInstance(CLSID_ObjectB,NULL, CLSCTX_LOCAL_SERVER);

> This causes a deadlock.
> I'm trying to understand what am i doing and how should i do it right, but
> please, if you can give me a clue.

> Thanks for your help
> Andrea



Fri, 25 Feb 2005 16:06:16 GMT  
 deadlock
Hopefully you don't do this from within DllMain... Otherwise
a deadlock is about guaranteed...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> Hello,
> I have a project(service) that includes 2 Objects :
> ObjectA, Object B with apartment threading model.
> A method of ObjectA must create an instance of Object B, so I call:

> CComPtr<IObjectB> m_objB
> m_objB.CoCreateInstance(CLSID_ObjectB,NULL, CLSCTX_LOCAL_SERVER);

> This causes a deadlock.
> I'm trying to understand what am i doing and how should i do it right, but
> please, if you can give me a clue.

> Thanks for your help
> Andrea



Sat, 26 Feb 2005 02:32:38 GMT  
 deadlock
Th OP says he/she has a service, which has to be an EXE, right?

I suspect ObjectA is a singleton, and thus an instance gets created
inside RegisterClassObjects during the service start-up, so
CoCreateInstance for ObjectB is called from start-up too, but its class
factory is not registered yet, so CoCreateInstance waits for the service
to start up and register the class factory, but of course the service
cannot do that because it is waiting for CoCreateInstance to return.
Catch-22.

I'd just create an internal instance with CComObject::CreateInstance.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Hopefully you don't do this from within DllMain... Otherwise
a deadlock is about guaranteed...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Hello,
> I have a project(service) that includes 2 Objects :
> ObjectA, Object B with apartment threading model.
> A method of ObjectA must create an instance of Object B, so I call:

> CComPtr<IObjectB> m_objB
> m_objB.CoCreateInstance(CLSID_ObjectB,NULL, CLSCTX_LOCAL_SERVER);

> This causes a deadlock.
> I'm trying to understand what am i doing and how should i do it right,
but
> please, if you can give me a clue.

> Thanks for your help
> Andrea



Sat, 26 Feb 2005 02:45:25 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How do I debug aspnet_wp.exe deadlocks?

2. GDI+ CImage deadlock

3. multiserver deadlock detection problem

4. Thread Pool Deadlock -- need help!

5. Timeouts and suspected thread deadlocks

6. Reader-Writer prob deadlock free?

7. unix c deadlock program...

8. Deadlock in Access through ODBC

9. Help: Deadlocks using SQL ODBC driver in ISAPI

10. ATL Service Deadlock

11. Deadlock allocating memory

12. ODBC call's to Close() causes deadlocks??!!

 

 
Powered by phpBB® Forum Software