Interop Events

  • Thread starter Thread starter Stryker.Ninja
  • Start date Start date
S

Stryker.Ninja

First time poster, please be gentle :P

I am using a third party ocx control in a C# 2.0 application. The
interop seems to be working fine except for events. When I try and
attach an event, it only succeeds for one event at a time. Examples:

// works by itself
OCXClass.Event1 += new OCXClass.EventHandler(Event1_Sub);

// second call fails
OCXClass.Event1 += new OCXClass.Event1Handler(Event1_Sub);
OCXClass.Event2 += new OCXClass.Event2Handler(Event2_Sub);

// works, but Event 2 is only thing available
OCXClass.Event1 += new OCXClass.Event1Handler(Event1_Sub);
OCXClass.Event1 -= new OCXClass.Event1Handler(Event1_Sub);
OCXClass.Event2 += new OCXClass.Event2Handler(Event2_Sub);

Has anyone seen this type of behavior before? thanks in advance for
any tips.
 
Hi Stryker,
// second call fails
OCXClass.Event1 += new OCXClass.Event1Handler(Event1_Sub);
OCXClass.Event2 += new OCXClass.Event2Handler(Event2_Sub);

By "fails" do you mean that an Exception is thrown? If so I'd assume that the error has to do with an implementation detail of the
control and since the control is third-party it's hard to say what could actually be happening. Post the error if you can. You
might want to contact the control's vendor or creator on this one.
 
Thanks Dave,

I did mean exception thrown. Here it is:

[System.Runtime.InteropServices.COMException] = {"Exception from
HRESULT: 0x80040202"}
StackTrace = " at
System.Runtime.InteropServices.ComTypes.IConnectionPoint.Advise(Object
pUnkSink, Int32& pdwCookie)\r\n at
WTReaderNet.ILRXReaderNetXEvents_EventProvider.add_OnTagMovedReader(ILRXReaderNetXEvents_OnTagMovedReaderEventHandler
)\r\n at WTReaderNet.L...

I kind of thought it was too generic to post.

I have contacted the vendor with no response yet, but I have a feeling
it will be "we don't support .Net implementation" since the examples
they give are all in VB6. I was kind of hoping that interop was to
blame, and that someone else had seen a similar problem and had a
workaround.
 
Hi Styrker,

Postng the error info did the trick. I searched for "HRESULT 0x80040202" on groups.google.com and found the following thread that
seems to address your issue (first of the results):

http://groups.google.com/group/micr...eaec54e3a5b?lnk=st&q=&rnum=1#b0924eaec54e3a5b

HTH

--
Dave Sexton

Stryker said:
Thanks Dave,

I did mean exception thrown. Here it is:

[System.Runtime.InteropServices.COMException] = {"Exception from
HRESULT: 0x80040202"}
StackTrace = " at
System.Runtime.InteropServices.ComTypes.IConnectionPoint.Advise(Object
pUnkSink, Int32& pdwCookie)\r\n at
WTReaderNet.ILRXReaderNetXEvents_EventProvider.add_OnTagMovedReader(ILRXReaderNetXEvents_OnTagMovedReaderEventHandler
)\r\n at WTReaderNet.L...

I kind of thought it was too generic to post.

I have contacted the vendor with no response yet, but I have a feeling
it will be "we don't support .Net implementation" since the examples
they give are all in VB6. I was kind of hoping that interop was to
blame, and that someone else had seen a similar problem and had a
workaround.
 
Back
Top