Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
Comments
Eugen Podsypalnikov at 6-Jul-11 9:54am
   
In general case
you could begin at CoCreateInstance(..) function :)
See also: http://www.jj54.com/73850-CoCreateInstance-Fails-On-COM-43-Object-With-Object-Construction-Enabled-And-No-Constructor-String-Present/
Ryan Zahra at 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 at 6-Jul-11 10:10am
   
Probably I would use some interface(s) of an COM+ object in the same (COM) way... :)
Ryan Zahra at 6-Jul-11 10:12am
   
Thanks for your reply. Do you have any examples please?
Eugen Podsypalnikov at 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,
NULL,
CLSCTX_INPROC_SERVER,
IID_MYLAYER,
(void**) &m_pIMPILayer);
if (S_OK == hr && m_pIMPILayer) {
m_pIMPILayer->SomeMethodeCall(..)
...
}
}
Ryan Zahra at 6-Jul-11 10:24am
   
Thanks! So this is exactly just like calling a normal COM object.
Eugen Podsypalnikov at 6-Jul-11 10:29am
   
Yes, I see it so (too) :) The COM+ is an extension (not a replacement) for the COM...
Ryan Zahra at 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 at 6-Jul-11 10:48am
   
Try to find (or generate) an *.?dl (in my case an *.idl) file :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Ryan Zahra at 8-Jul-11 3:10am
   
Thanks a lot :)
Rate this: bad
good
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.
  Permalink  
Comments
Marcus Kramer at 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 at 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
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 7 Jul 2011
Copyright © CodeProject, 1999-2014
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