From: Stryker.Ninja on
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.

From: Dave Sexton on
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.

--
Dave Sexton

<Stryker.Ninja(a)gmail.com> wrote in message news:1153944207.436565.9670(a)b28g2000cwb.googlegroups.com...
> 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.
>


From: Stryker on
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.

Dave Sexton wrote:
> 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.
>
> --
> Dave Sexton
>
> <Stryker.Ninja(a)gmail.com> wrote in message news:1153944207.436565.9670(a)b28g2000cwb.googlegroups.com...
> > 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.
> >

From: Dave Sexton on
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/microsoft.public.dotnet.languages.csharp/browse_frm/thread/62fe9e0a42604e49/b0924eaec54e3a5b?lnk=st&q=&rnum=1#b0924eaec54e3a5b

HTH

--
Dave Sexton

"Stryker" <Stryker.Ninja(a)gmail.com> wrote in message news:1154005804.255353.131760(a)i3g2000cwc.googlegroups.com...
> 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.
>
> Dave Sexton wrote:
>> 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.
>>
>> --
>> Dave Sexton
>>
>> <Stryker.Ninja(a)gmail.com> wrote in message news:1153944207.436565.9670(a)b28g2000cwb.googlegroups.com...
>> > 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.
>> >
>