getting events into c# app from a COM control - critical path help needed!

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Hi, I have a COM control / server I'm trying to get events from in my c#
applications.

1) I'm trying to get events in both c# console apps and in c# winform apps.
2) I can call methods on the COM control / server ok, I just don't receive
any events. The method calls are definitely successful.
3) I have got events and communicated ok with other COM controls from c# -
it's just this one I have a problem with.
4) I can communicate perfectly with the COM control / server from VB and
VC6 - both methods and events work fine.
5) I've tried STA and MTA and have used the control directly and via
tlbimp.exe

It looks like there is a problem with this particular control - is that
possible? I've tried sinking the events via delagates:
objControl.OnDisable += new IControlEvents_OnDisableEventHandler(OnDisable);
objControl.OnEnable += new IControlEvents_OnEnableEventHandler(OnEnable);

and by setting up an event sink:
// Create the object.
ControlProxy objControlProxy = new ControlProxyClass();

// Fix the connection points to fire events.
m_objIConnectionPointContainer =
(UCOMIConnectionPointContainer)objControlProxy;
Guid objGuid = typeof(eventtlbnsp.IControlEvents).GUID;
m_objIConnectionPointContainer.FindConnectionPoint(ref objGuid, out
m_objIConnectionPoint);
m_objIConnectionPoint.Advise(this, out m_nCookie);

Any help is SINCERELY appreciated, I'm really on the critical path on this.
I've looked all over the ng's - people have been asking about this for years
but I can't find any answers which work on this.

Cheers, Dave.
 
Hi Dave,

Delegates are usually the way to go, they work fine for me. You can examine
the interop assembly with ildasm to see whether event arguments were
generated correctly.
 
They don't work on this I'm afriad.

I think something dodgy is going on inside the control that is incompatible
with the CLR. My VB6 project (which just creates the control and receives
the events - 5 lines of programming) works perfectly, but when I convert it
to VB.Net, it stops working and behaves just like the c# project.

If I create a VB6 control (exe or dll) that wraps the 3rd party control (ie,
feeds method calls straight through, sends events straight out), and use the
VB6 control from c#, it works perfectly. Once I've got some time, I'll write
a VC++ wrapper.


Dmitriy Lapshin said:
Hi Dave,

Delegates are usually the way to go, they work fine for me. You can examine
the interop assembly with ildasm to see whether event arguments were
generated correctly.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

dave said:
Hi, I have a COM control / server I'm trying to get events from in my c#
applications.

1) I'm trying to get events in both c# console apps and in c# winform
apps.
2) I can call methods on the COM control / server ok, I just don't receive
any events. The method calls are definitely successful.
3) I have got events and communicated ok with other COM controls from c# -
it's just this one I have a problem with.
4) I can communicate perfectly with the COM control / server from VB and
VC6 - both methods and events work fine.
5) I've tried STA and MTA and have used the control directly and via
tlbimp.exe

It looks like there is a problem with this particular control - is that
possible? I've tried sinking the events via delagates:
objControl.OnDisable += new
IControlEvents_OnDisableEventHandler(OnDisable);
objControl.OnEnable += new IControlEvents_OnEnableEventHandler(OnEnable);

and by setting up an event sink:
// Create the object.
ControlProxy objControlProxy = new ControlProxyClass();

// Fix the connection points to fire events.
m_objIConnectionPointContainer =
(UCOMIConnectionPointContainer)objControlProxy;
Guid objGuid = typeof(eventtlbnsp.IControlEvents).GUID;
m_objIConnectionPointContainer.FindConnectionPoint(ref objGuid, out
m_objIConnectionPoint);
m_objIConnectionPoint.Advise(this, out m_nCookie);

Any help is SINCERELY appreciated, I'm really on the critical path on
this.
I've looked all over the ng's - people have been asking about this for
years
but I can't find any answers which work on this.

Cheers, Dave.
 
Back
Top