Knowledge Base
PRB: WithEvents Does Not Work with Remote AutomationPSS ID Number: 172312
Article Last Modified on 4/18/2003
--------------------------------------------------------------------------------
The information in this article applies to:
a.. Microsoft Visual Basic Control Creation Edition for Windows 5.0
b.. Microsoft Visual Basic Learning Edition for Windows 5.0
c.. Microsoft Visual Basic Professional Edition for Windows 5.0
d.. Microsoft Visual Basic Enterprise Edition for Windows 5.0
--------------------------------------------------------------------------------
This article was previously published under Q172312
SYMPTOMS
When attempting to raise a remote event across Remote Automation, the
following run-time error appears:
-2147467259(80004005) , Automation error
CAUSE
Remote Automation does not currently support the use of WithEvents.
RESOLUTION
To support remote events with Visual Basic 5.0, use DCOM instead of Remote
Automation. You can also use callbacks to simulate raising events remotely.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
Use the following steps on the server machine:
1.. Start Visual Basic 5.0 and create a new ActiveX EXE project.
2.. From the Project menu, selectProject properties and change the Project
name to "Projtest."
3.. Add a Class Module and change its name to "Testclass."
4.. In Testclass' Code window, input following code:
Public Event propchange(newv As String)
Private propt As String
Public Sub showfrm()
MsgBox "asdfl"
End Sub
Public Property Get testp() As String
testp = propt
End Property
Public Property Let testp(ByVal vNewValue As String)
propt = vNewValue
RaiseEvent propchange(propt)
End Property
5.. On the File menu, click "Make ProjTest.exe."
6.. Copy the corresponding .exe, .tlb, and .vbr files to the client
machine.
7.. Start the Automation Manager and the RemAuto Connection Manager to set
necessary server-side configuration for using Projtest.testclass for Remote
Automation.
Use the following steps on the client machine:
1.. Run Projtest.exe, which was copied from the Server side in the above
steps.
2.. Start the RemAuto Connection Manager to set necessary Client-side
configuration for using Projtest.testclass.
3.. Launch Visual Basic 5.0 and create a new Standard EXE project with a
standard form.
4.. From the Project menu, click References and select the "Projtest" box.
5.. In Form1's Code window, input following code:
Public WithEvents eventp As testclass
Private Sub eventp_propchange(newv As String)
MsgBox newv
End Sub
Private Sub Form_Load()
Dim a As New testclass
a.showfrm
Set eventp = a
a.testp = "test string"
End Sub
6.. Run the project and check if the Remote Automation connection is
correct, the message box should pop up on the server-side machine.
7.. Click OK to close the message box on the server-side machine.
Result
When the line "Set eventp = a" executes, you will get the following run-
time error:
-2147467259(80004005) , Automation error
Expected behavior
A message box should appear on the client-side machine because the server
raised the Propchange event.
NOTE: If both the client and the server are running on the same machine
(with local automation), you will see the expected behavior.
Keywords: kbprb KB172312
Technology: kbAudDeveloper kbVB500 kbVB500Search kbVBA500Search kbVBSearch
kbZNotKeyword2 kbZNotKeyword3 kbZNotKeyword6
--------------------------------------------------------------------------------
Send feedback to Microsoft
© 2003 Microsoft Corporation. All rights reserved.
--
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
There's no place like 127.0.0.1
"Jonas" <ba*******@hotmail.com> wrote in message
news:2V********************@newsc.telia.net...
: This is the error message:
:
: Run-time error '-2147023067 (80070725)':
: Automation error
:
:
:
: "Randy Birch" <rg************@mvps.org> skrev i meddelandet
: news:wA*******************@news04.bloor.is.net.cab le.rogers.com...
: > "does not work" is insufficient. What is the error message.
: >
: > --
: >
: > Randy Birch
: > MVP Visual Basic
: >
http://vbnet.mvps.org/
: > Please respond only to the newsgroups so all can benefit.
: >
: > There's no place like 127.0.0.1
: >
: >
: > "Jonas" <ba*******@hotmail.com> wrote in message
: > news:ZY********************@newsb.telia.net...
: > : This works fine in Win XP but does not work at all in Win 98.
: > : Private WithEvents objIExplorer As InternetExplorer
: > :
: > : I have to do it like this to get it to work in Win 98
: > : Dim objIExplorer As InternetExplorer But then I cant see when a user
: exit
: > my
: > : objIExplorer and than an error will show up when I try to open a link
in
: > the
: > : IE window that does not exist...
: > :
: > : What can I do about this and way does it not work in win 98?
: > :
: > : (This does not work at all with Private WithEvents objIExplorer As
: > : InternetExplorer)
: > : If objIExplorer Is Nothing Then
: > : Set objIExplorer = New InternetExplorer ' ******* Here is where
the
: > : Error will show up****
: > : With objIExplorer
: > : .AddressBar = True
: > : .MenuBar = True
: > : .StatusBar = True
: > : .ToolBar = True
: > : .Visible = True
: > : DoEvents
: > : End With
: > : End If
: > :
: > : Yours, Jonas
: > :
: > :
: >
: >
:
: