Microsoft KB Archive/190523

= PRB: Automation Error (-2147417843) When You Use the Taskbar Notification Area =

Article ID: 190523

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q190523



SYMPTOMS
When you use the Shell_NotifyIcon function or the SysTray control sample from the Visual Basic CD-ROM, you may receive the following error message:

Run-time error: -2147417843 (8001010d)

Automation Error



CAUSE
The run-time error occurs because you are trying to make an Automation call to an out-of-process (ActiveX) EXE from within the event notification of the Taskbar Notification Area callback. The value -2147417843 translates to the following error message:

An outgoing call cannot be made since the application is dispatching an input-synchronous call.

Automation clients are required by COM to process input-synchronous calls without interruption, and therefore are prevented from making outgoing Automation calls while processing such messages.



RESOLUTION
Avoid making outgoing Automation calls during the Taskbar Notification Area callback. If an Automation method needs to be called in response to a user event involving the Taskbar Notification Area, use a simple Timer to post yourself a message, and then let the callback function complete. When the Timer event fires, you can safely call your Automation method.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Copy the SysTray control sample from the Tools\Unsupprt folder of the Visual Basic 5.0 CD-ROM, or the Common\Tools\VB\Unsupprt folder of the Visual Basic 6.0 CD-ROM, to your hard drive. Open the project and compile the control. When complete, close the project. Create a new Standard EXE project. Form1 is created by default. From the Project menu, click Components, and check System Tray Icon Control. Click OK. Select the SysTray control in the toolbox and add an instance to Form1.</li>  Add the following code into Form1's code window: Option Explicit Private oWord As Object

Private Sub Form_Load Set oWord = CreateObject("Word.Application") Set cSysTray1.TrayIcon = Me.Icon cSysTray1.InTray = True End Sub

Private Sub Form_Unload(Cancel As Integer) cSysTray1.InTray = False Set oWord = Nothing End Sub

Private Sub cSysTray1_MouseDblClick(Button As Integer, Id As Long) oWord.Visible = True End Sub </li> Run the application by pressing the F5 key. The error occurs when you double-click the application's icon in the System Tray. Press the END key to stop the debugger.</li> To avoid the error, add a Timer to Form1.</li>  Replace the code in Form1 with the following: Option Explicit Private oWord As Object

Private Sub Form_Load Set oWord = CreateObject("Word.Application") Set cSysTray1.TrayIcon = Me.Icon cSysTray1.InTray = True Timer1.Enabled = False Timer1.Interval = 10 End Sub

Private Sub Form_Unload(Cancel As Integer) cSysTray1.InTray = False Set oWord = Nothing End Sub

Private Sub cSysTray1_MouseDblClick(Button As Integer, Id As Long) Timer1.Enabled = True End Sub

Private Sub Timer1_Timer Timer1.Enabled = False oWord.Visible = True End Sub </li> Re-run the application by pressing the F5 key. This time no error should occur.</li></ol>

<div class="references_section">