Click here to Skip to main content
15,570,042 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a couple of questions about developing an out-of-proc (local) COM server using ATL.

I need to figure out how to make the server function as a single instance. Currently, any call by a client app to CoCreateInstance will launch a new instance of my server. Is there a macro or define that I am missing?

I am also having trouble getting QueryInterface to work properly on an exposed class. I can only get a IUnknown ptr to my object. If the client calls QueryInterface to get a different interface, I can see via traces (from defining _ATL_DEBUG_INTERFACES and _ATL_DEBUG_QI) that the QI call on my object (in the exe) succeeds, but but the refcount is only going to 1, then QI succeeds, then release is called, dropping the refcount back to 0. (I am using the singleton class factory.) The call in the client is returning E_NOINTERFACE.

I would appreciate any ideas or suggestions on where to get help.

Thanks.

Wayne
Posted

to get your server to be a single instance you need to modify the call to RegisterClassObjects to

hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE);
 
Share this answer
 
Ma-an, just stop it right there before you start. Nobody in his right mind starts on DCOM Server projects these days. It has been obsolete for a few years now, since Vista came out first.

What you need to develop is a Windows Service ;)
 
Share this answer
 
Comments
Stephen Hewitt 10-Jun-10 23:24pm    
Reason for my vote of 1
COM is far from dead. It's not the right tool for every job and for some things where in the past you'd have used may be better implemented using newer technologies, but that doesn't mean there aren't jobs where it's useful. Also note that COM is essentially a packing technology: it describes what servers look like on the outside, but they can be implemented in many languages including C#.


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900