PRB: VB5.0 OLE Automation Error - 2147418107 (80010005)Last reviewed: January 27, 1998Article ID: Q176399 |
The information in this article applies to:
SYMPTOMSWhen a compiled Visual Basic 5.0 application makes calls to an ActiveX server via a timer event, the following error may occur:
"Run-time error '-2147418107 (80010005)': Automation error" CAUSEAfter the first WM_TIMER event is fired, subsequent WM_TIMER events cannot be processed until the first event is completed. The error message equates to:
"It is illegal to call out while inside message filter." RESOLUTIONThree workarounds have been implemented with success:
Workaround 1Set a boolean flag in the timer event (see code listed in the Steps to Reproduce Behavior section below).
Public flag As Boolean Private Sub Timer1_Timer() If Not flag Then flag = True RetStr = t.Test(100000) flag = False End If Text1.Text = RetStr End SubBy doing this, the timer can't call the server until the previous call is completed.
Workaround 2Create the server as a DLL, not an EXE. ActiveX DLLs are in-process servers. An in-process server would not use Remote Procedure Call engine (RPC). (See the MORE INFORMATION below.)
Workaround 3Place error handling in effect to ignore the error:
Private Sub Timer1_Timer() On Error Resume Next RetStr = t.Test(100000) End Sub STATUSThis behavior is by design.
MORE INFORMATIONTimers in Microsoft Windows are fired by Windows placing WM_TIMER messages in a windows message queue. For example, an application receives the first timer's WM_TIMER message in its window proc. This causes Visual Basic to fire the first timer's Timer event, which calls the ActiveX server through the Remote Procedure Call engine (RPC) because ActiveX EXE servers run in a separate process. While the Visual Basic application is waiting for the RPC call to complete, the RPC engine allows the Visual Basic application to sit and poll its message queue. This is allowed primarily for screen redraw (if WM_PAINT messages come in because the user was switching around windows), so the application can update its windows while it is waiting for the RPC call to complete. If, while Visual Basic waits for the first RPC call to complete, it processes a second WM_TIMER message coming in through the RPC message filter, this causes Visual Basic to fire the second timer's Timer event, which attempts to call the ActiveX server again through the RPC engine. However, the RPC engine explicitly does not allow an application to make an RPC call when it is in the RPC message filter, so it returns an error that Visual Basic returns to the user. At the point at which Visual Basic gets the WM_TIMER message, there is no way for Visual Basic to know whether firing the Timer event will cause an RPC call to be made. In fact, because ActiveX servers can be transparently remote, there is no way for Visual Basic to know, when it is calling an object method, whether that method will be routed through the RPC engine. Thus, there is no way for Visual Basic to know ahead of time that the RPC engine is going to throw an error.
Steps to Reproduce BehaviorNote: Error will not reproduce unless the projects have been compiled.
Server
Client
Keywords : vb5all kberrmsg Technology : ole Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |