Offending code:
Dim Test as pwrworld.SimulatorAutoWithEvents
Test = New pwrworld.SimulatorAutoWithEvents()
AddHandler Test.ErrorMessage, AddressOf ErrorMessageHandler
AddHandler Test.DialogBox, AddressOf DialogBoxHandler
The code works fine if I comment out either of the AddHandler statements,
but always fails when they are both there. As further reference,
pwrworld.SimulatorAutoWithEvents is created using Delphi 7. As Delphi's
.NET support is not currently very good and would require a rewrite of the
main application, I am forced to use COM interfacing rather than a .NET
interface.
The COM object works fine within VBA using "Dim WithEvents Test as
pwrworld.SimulatorAutoWithEvents" and adding the relevant subroutines. My
guess is that the object would work equally well in VB 6, but I don't have a
license or copy of VB 6 to check.
Any alternative fixes/workarounds would be greatly appreciated, or maybe
even a patch to .NET's tlbimp which adequately addresses this known bug.
Thanks,
Zeb Tate
COM class in VB6( and ActiveX dll):
Public Event e()
Public Sub raiser()
RaiseEvent e
End Sub
.NET console application that has a reference to the ActiveX dll creatd
usng the code above:
Imports Project1
Module Module1
Sub Main()
Dim o As New c1
o.bar()
End Sub
Class c1
Public WithEvents var As Class1Class
Sub bar()
var = New Class1Class
AddHandler var.e, AddressOf handler1
AddHandler var.e, AddressOf handler2
var.raiser()
End Sub
Sub handler1()
Console.WriteLine("1")
End Sub
Sub handler2()
Console.WriteLine("2")
End Sub
End Class
End Module
Both my event handlers are getting called. Can you send some sample code
that will help repro your problem.
thanks
Manish
VB Language Team
I'm creating my COM automation server in Delphi 7. I can send you a copy of
the exe, code, and/or TLB if necessary via email. The COM object works fine
in VBA; maybe it has something to do with early vs. late binding? There
have been previous posts with the same problem, e.g.:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=105c101c
21c6e%2415f5dd50%2436ef2ecf%40tkmsftngxa12&rnum=3&prev=/groups%3Fhl%3Den%26l
r%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DHRESULT%2Baddhandler
I've already tried the solution outlined in
http://support.microsoft.com/default.aspx?scid=kb;;Q316653
but it did not help.
-Zeb
----- Original Message -----
From: "Manish JAyaswal" <man...@microsoft.com>
Newsgroups: microsoft.public.dotnet.languages.vb
Sent: Monday, August 04, 2003 3:51 PM
Subject: RE: AddHandler fails when adding a second event handler, HRESULT
0x80040202
> Hi Zeb,
> I am not able to repro your prombel here. I tried with a simple COM dll
and
> added 2 handlers to it and it is working fine. Here is the code I used:
>
> COM class in VB6( and ActiveX dll):
>
> Public Event e()
> Public Sub raiser()
> RaiseEvent e
> End Sub
>
Alex
--------------------
>From: "Zeb Tate" <zeb...@remove.me.hotmail.com>
>References: <e6p6eJVT...@tk2msftngp13.phx.gbl>
<kNS23osW...@cpmsftngxa06.phx.gbl>
>Subject: Re: AddHandler fails when adding a second event handler, HRESULT
0x80040202
>Date: Tue, 5 Aug 2003 10:29:13 -0500
>Lines: 76
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>Message-ID: <ewll#X2WDH...@TK2MSFTNGP11.phx.gbl>
>Newsgroups: microsoft.public.dotnet.languages.vb
>NNTP-Posting-Host: powerworld-serv.powerworld.com 192.17.60.35
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:125499
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
This is an automatically generated Delivery Status Notification.
Delivery to the following recipients failed.
Reporting-MTA: dns;hotmail.com
Received-From-MTA: dns;mail.hotmail.com
Arrival-Date: Mon, 18 Aug 2003 08:34:39 -0700
Final-Recipient: rfc822;amo...@online.microsoft.com
Action: failed
Status: 5.0.0
Any ideas?
-Zeb
"Alexandre Moura" <amo...@online.microsoft.com> wrote in message
news:mcjH0XrY...@cpmsftngxa06.phx.gbl...