Hi guys,
Hope someone here can help. I am performing something almost identical to
the sample shown here, except my .NET server class has a private constructor
and a shared factory method to create an instance of itself.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
concominteropsamplecomclientnetserver.asp
Unfortunately the following lines of code, do not return an interface to my
COM client:
HRESULT hr = CoInitialize(NULL);
IClassPtr pIClass(__uuidof(Class));
What do I need to do in C++/COM in order to get around this problem.
Changing the design of my .NET class is not an option for me.
Thanks in advance,

Signature
Nick Wilton BSc(Hons) MCP
C++ Consultant
www.darwinconsultants.co.uk
Rodrigo Corral [MVP] - 13 May 2005 16:07 GMT
Here,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conqualifyingnettypesforinteroperation.asp,
at MSDN documentation you can read:
" Types must have a public default constructor to be activated from COM.
Managed, public types are visible to COM. However, without a public default
constructor (a constructor with no arguments), COM clients cannot create the
type. COM clients can still use the type if it is activated by some other
means. "
You always can have a public class with a public constructor and a method
that returns an new instance of your class. You must put one internal
constructor in your current class which only would be callable from inside
your assembly.

Signature
Un saludo
Rodrigo Corral González [MVP]
FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org