Event Sink for a COM object which raises events - Proof of Concept 
Author Message
 Event Sink for a COM object which raises events - Proof of Concept

All

I am having a lot of problems setting up an Event Sink in C# for a VB6 Com
object which has events.
A couple of lines of code is worth more than a 1000 of words of my
explanation so...

Here is my code..
In an Project in vb6 I have a Class called SimpleClass (Public MultiUse)

Public Event OnStartup()

Public Sub Start()
    RaiseEvent OnStartup
End Sub

Create as an ActiveX DLL

All I want to do is create the Class in C# (using the generated COMWrapper)
and be able to respond to events in my C# code... I have so far seen no
examples of how to do this...

ie.

In CSharp I would like to:
    1) Create the Object (easy can do this now) ie "SimpleClass sc = new
SimpleClass();"
    2) Attach to the Event (so far I have no idea how to do this... the
OnStartup event is exposed on one of the interfaces generated, but I can't
seem to get to that interface! so I can't use it)
    3) Directly call "SimpleClass.Start()" in C#
    4) Respond in my C# code to the OnStartup event that is fired by 3)

Any pointers would be appreciated...

Alex



Sat, 18 Oct 2003 21:29:58 GMT  
 Event Sink for a COM object which raises events - Proof of Concept
Did you try treating "OnStartup" as a event delegate?
In the Framework SDK documentation it says:

Simulating COM Interfaces
IConnectionPoint and IConnectionPointContainer
For objects that source delegate-based events (an interface for registering
event subscribers).
(cpguide.chm::/html/cpconsimulatingcominterfaces.htm)

I'm very interested in this but right now I don't have
time to try. If it went OK please let me and everyone know
how you did it.
Thanks.



Quote:
> All

> I am having a lot of problems setting up an Event Sink in C# for a VB6 Com
> object which has events.
> A couple of lines of code is worth more than a 1000 of words of my
> explanation so...

> Here is my code..
> In an Project in vb6 I have a Class called SimpleClass (Public MultiUse)

> Public Event OnStartup()

> Public Sub Start()
>     RaiseEvent OnStartup
> End Sub

> Create as an ActiveX DLL

> All I want to do is create the Class in C# (using the generated
COMWrapper)
> and be able to respond to events in my C# code... I have so far seen no
> examples of how to do this...

> ie.

> In CSharp I would like to:
>     1) Create the Object (easy can do this now) ie "SimpleClass sc = new
> SimpleClass();"
>     2) Attach to the Event (so far I have no idea how to do this... the
> OnStartup event is exposed on one of the interfaces generated, but I can't
> seem to get to that interface! so I can't use it)
>     3) Directly call "SimpleClass.Start()" in C#
>     4) Respond in my C# code to the OnStartup event that is fired by 3)

> Any pointers would be appreciated...

> Alex



Sat, 18 Oct 2003 23:43:42 GMT  
 Event Sink for a COM object which raises events - Proof of Concept
Quote:
> (cpguide.chm::/html/cpconsimulatingcominterfaces.htm)

this is like

\
dotNET%20Framework%20Documentation\cpguide.chm::/html/cpconsimulatingcominte
rfaces.htm

in case you didn't know



Sat, 18 Oct 2003 23:54:46 GMT  
 Event Sink for a COM object which raises events - Proof of Concept
Thanks for your input Cramoisi?

we have a workaround of sorts, see the Thread "Capturing Outlook Events in
C#"... This is exactly the same problem.

Cheers
Alex


Quote:
> Did you try treating "OnStartup" as a event delegate?
> In the Framework SDK documentation it says:

> Simulating COM Interfaces
> IConnectionPoint and IConnectionPointContainer
> For objects that source delegate-based events (an interface for
registering
> event subscribers).
> (cpguide.chm::/html/cpconsimulatingcominterfaces.htm)

> I'm very interested in this but right now I don't have
> time to try. If it went OK please let me and everyone know
> how you did it.
> Thanks.



> > All

> > I am having a lot of problems setting up an Event Sink in C# for a VB6
Com
> > object which has events.
> > A couple of lines of code is worth more than a 1000 of words of my
> > explanation so...

> > Here is my code..
> > In an Project in vb6 I have a Class called SimpleClass (Public MultiUse)

> > Public Event OnStartup()

> > Public Sub Start()
> >     RaiseEvent OnStartup
> > End Sub

> > Create as an ActiveX DLL

> > All I want to do is create the Class in C# (using the generated
> COMWrapper)
> > and be able to respond to events in my C# code... I have so far seen no
> > examples of how to do this...

> > ie.

> > In CSharp I would like to:
> >     1) Create the Object (easy can do this now) ie "SimpleClass sc = new
> > SimpleClass();"
> >     2) Attach to the Event (so far I have no idea how to do this... the
> > OnStartup event is exposed on one of the interfaces generated, but I
can't
> > seem to get to that interface! so I can't use it)
> >     3) Directly call "SimpleClass.Start()" in C#
> >     4) Respond in my C# code to the OnStartup event that is fired by 3)

> > Any pointers would be appreciated...

> > Alex



Sun, 19 Oct 2003 19:35:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ATL COM Component firing events into VBScript event sink

2. Event sink from other COM object ?

3. creating a sink in VC to handle events fired by VB Com Object

4. Implemeting event sink for COM objects

5. NullReferenceException thrown when raising an event where there are no event handlers attached

6. ATL DLL event sink with a VB ActiveX DLL event source

7. Fire an Event, sink a event - Help!

8. How to event sink to events in the same IDispatch derived class

9. Receive the Event raised by an VB COM

10. Raising a Click event from an ASP:Label object

11. Raising and catching event within an object hierachy

12. Event Sink is Not Working for EXE COM

 

 
Powered by phpBB® Forum Software