I have a .Net COM server that has a method that takes a message and a delay as parameters. After the delay, it fires an event sending the message back to the client.
It works with .Net and VB6 clients.
In order to get the COM event to bind in FoxPro, you have to create a class that implements the event interface in foxpro and wire it up, as described here: http://www.west-wind.com/presentations/dotnetfromVfp/DotNetFromVfp_EventHandling.asp
I have such a class:
DEFINE CLASS ComEventHandler AS session OLEPUBLIC
IMPLEMENTS IComServerEvents IN "PcaTest.ComServer"
* "C:\ComTest\PCATest.tlb"
PROCEDURE IComServerEvents_TimerExpired(message AS STRING) AS VOID
* add user code here
?message
ENDPROC
ENDDEFINE
And the code to wire this up:
loMM = CREATEOBJECT("PcaTest.ComServer")
loEvents = CREATEOBJECT("ComEventHandler")
EventHandler(lomm, loevents)
When I run this code, I get Type Library PcaTest.ComServer not found. However, it works as expected if I change the implements line to:
IMPLEMENTS IComServerEvents IN "C:\ComTest\PCATest.tlb"
I can't hard-code the location of the tlb.
The line "CREATEOBJECT("PcaTest.ComServer")" works fine, actually, and if I don't try to instantiate a ComEventHandler object, that COM object is instantiated and I can call its methods and access its properties. The event handler class is (mostly) only working when I feed it the .tlb and not the progId.
The .Net COM server is registered in the GAC. I've tried regasm with and without /codebase and with and without /tlb or /tlb:filename.tlb
I did have this working in testing at one point, or so it seemed. I am unable to duplicate those results now, but when I had it working I had used /codebase and /tlb:filename.tlb.