Problem with Event sink (ATL C++) when the event source is a C# object

Problem with Event sink (ATL C++) when the event source is a C# object

Post by Cristian M » Fri, 10 Feb 2006 03:19:30



Hello everybody,

I need to send from a C# object events, that have to be caught
in my C++ code. I have followed the instructions from the MSDN article
"Raising Events Handled by a COM Sink", but I have a problem
when I call AtlAdvise in the C++ client: the method FindConnectionPoint
will fail with error CONNECT_E_NOCONNECTION (0x80040200).

So I suppose there is a problem with the connetion point map. I found
in another posting that the event instance name has to be the same as the
interface method, which I did, but with no result.

How can I solve my problem? Stupid ideea: is there any way to define
(correct)
manually the message map for the C# object, like it was possible in C++?

Many thanks for your help,
Cristian
 
 
 

Problem with Event sink (ATL C++) when the event source is a C# object

Post by Willy Deno » Sun, 12 Feb 2006 06:05:59


|
| Hello everybody,
|
| I need to send from a C# object events, that have to be caught
| in my C++ code. I have followed the instructions from the MSDN article
| "Raising Events Handled by a COM Sink", but I have a problem
| when I call AtlAdvise in the C++ client: the method FindConnectionPoint
| will fail with error CONNECT_E_NOCONNECTION (0x80040200).
|
| So I suppose there is a problem with the connetion point map. I found
| in another posting that the event instance name has to be the same as the
| interface method, which I did, but with no result.
|
| How can I solve my problem? Stupid ideea: is there any way to define
| (correct)
| manually the message map for the C# object, like it was possible in C++?
|
| Many thanks for your help,
| Cristian
|

Have you registered your .NET sassemby with Regasm /tlb /codebase <your.dll>
And is you C# class decorated correctly?

[ComSourceInterfaces(typeof(IYourEventsInterface))]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]

Willy.

 
 
 

Problem with Event sink (ATL C++) when the event source is a C# object

Post by Cristian M » Tue, 14 Feb 2006 21:19:05


Hello,

and thank you for your reply. The C# class was decorated
properly, but I had a registration problem (my C# assembly
was registered twice, and this caused some kind of problem,
the system was trying the one registration with no connection points,
so the failure of the FindConnectionPoint method was normal).

So, I have fixed the registration and I can catch events now in my C++
code... :)

Kind regards,
Cristian