Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

COM Client / .NET Server with private constructor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick Wilton - 13 May 2005 12:39 GMT
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


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.