Click here to Skip to main content
11,922,641 members (32,037 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C# COM COM+ C#4.0
Hi All,

I have created a COM+ in C#. I have managed to use this COM+ object from another C# project successfully.

Now I would like to access this COM+ object from C++. Does anyone have any ideas on how I should do this? Maybe you could point me to some useful articles with examples.

Thanks in advance.
Posted 6-Jul-11 4:34am
Eugen Podsypalnikov 6-Jul-11 9:54am
In general case
you could begin at CoCreateInstance(..) function :)
See also:
Ryan Zahra 6-Jul-11 10:03am
Thanks for your reply. I know how to use COM object in C++ using the CoCreateInstance function, however I'm still lost as how to use the COM+ object in C++.
Eugen Podsypalnikov 6-Jul-11 10:10am
Probably I would use some interface(s) of an COM+ object in the same (COM) way... :)
Ryan Zahra 6-Jul-11 10:12am
Thanks for your reply. Do you have any examples please?
Eugen Podsypalnikov 6-Jul-11 10:23am
static const CLSID CLSID_MYLAYER = {
0x9912EF9F, 0x0FF0, 0x42c1, { 0xAE, 0x6B, 0x74, 0x0C, 0xC8, 0x3D, 0x6D, 0xA8 } };

static const IID IID_MYLAYER = {
0x03A1EE13, 0x2CB6, 0x4b79, { 0xA4, 0xF6, 0x40, 0x65, 0xBB, 0xBE, 0x9B, 0x2B } };

void CSomeUser::SomeStart(..)
// IMPILayer* m_pIMPILayer = NULL; // Interface' pointer

HRESULT hr = CoCreateInstance(CLSID_MYLAYER,
(void**) &m_pIMPILayer);
if (S_OK == hr && m_pIMPILayer) {
Ryan Zahra 6-Jul-11 10:24am
Thanks! So this is exactly just like calling a normal COM object.
Eugen Podsypalnikov 6-Jul-11 10:29am
Yes, I see it so (too) :) The COM+ is an extension (not a replacement) for the COM...
Ryan Zahra 6-Jul-11 10:33am
Just one more question though...
In your example, you're using the interface IMPILayer. What should you include? I'm trying to include the .tlb file in my solution but still not having access to the interface. I could not even be able to find the namespace.
Eugen Podsypalnikov 6-Jul-11 10:48am
Try to find (or generate) an *.?dl (in my case an *.idl) file :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Ryan Zahra 8-Jul-11 3:10am
Thanks a lot :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The point of COM is that you shouldn't need to do anything different, regardless of the language used. So any tuturial on using COM+ from C++ should work fine.
Marcus Kramer 7-Jul-11 21:36pm
True, but I remember the first time I had to do this and the first time was excruciating. Mind you that was with dotNet1.1 where the COM interop facilities were a very manual process.
Ryan Zahra 8-Jul-11 3:10am
Exactly. The first time is always the most difficult until you get the hang of it. Once you do it at least once, it's pretty straight forward.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151125.1 | Last Updated 7 Jul 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100