CSExeComServer LateBinding Events

Dec 22, 2009 at 3:40 PM

All,

First off, I'm really impressed with the quality of this tool kit.  Well done!

I've been struggling with a problem for the last several days regarding latebinding and events.  I've based my test EXE Com server off the CSExeCOMServer project and followed some suggestions found on a forum about using latebinding to get an out-of-process EXE.  The Latebinding example does not have an example of how to capture events and this has been the source of my struggles. 

Currently my test client application is written in managed C++ since all the applications I will connect this to are managed C++.  I've been able to create a sink interface matching the COM event interface and was able to "Advise" using an IConnectionPoint without error.  Unfortunately, when FloatPropertyChanging is called in the COM server during the call to set_FloatProperty it throws a TargetInvocationException. 

Is there something I'm missing here about trying to capture these out-of-process events through late binding?  I'm starting to feel like I am missing something since the example doesn't include source for late binding event handling.

Any help here would be greatly appreciated.

Jim

Coordinator
Dec 23, 2009 at 8:02 AM
Edited Dec 23, 2009 at 12:39 PM

Hello Jim

Thanks for the appreciation. Please try these possible solutions. I have not tested them by myself. If they do not work, please let me know.

Possible Solution1.

Step1. Try to export the type library (.tlb) from the out-of-proc COM server by using tlbexp:

tlbexp CSExeCOMServer.exe /out:CSExeCOMServer.tlb

You will get CSExeCOMServer.tlb then.

Step2. Use ATL in your C++ project to register the event. (See the ATLCOMClient sample)

 

Possible Solution2

Register event through .NET Reflection

I don't know whether this works for COM events, but it deserves a trial:

http://skysigal.xact-solutions.com/Blog/tabid/427/EntryId/1003/-NET-Reflection-Wiring-up-Event-Handlers-using-Reflection-and-Delegates.aspx

 

Jialiang Ge