PRB: Automation Error (-2147417843) When You Use the
Taskbar Notification Area |
The information in this article applies to:
- Microsoft Visual Basic Learning, Professional, and Enterprise
Editions for Windows, versions 5.0, 6.0
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.
MORE INFORMATION
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.
- 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
- 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.
- To avoid the error, add a Timer to Form1.
- 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
- Re-run the application by pressing the F5 key. This time no
error should occur.
REFERENCES
For additional information about input-synchronous calls in COM
and this Automation error, click the article number below to view
the article in the Microsoft Knowledge Base:
Q131056
PRB: Synch OLE Call Fails in Inter-Process/Thread SendMessage
For additional information, please see the following
article in the Microsoft Knowledge Base:
Q176085
HOWTO: Use the Taskbar Notification Area Directly from Visual
Basic 5.0
Additional query words:
Keywords : kbAutomation kbVBp kbVBp500 kbVBp600 kbGrpVB
kbDSupport kbofficeprog Issue type : kbprb Technology : |
|
 When You Use the Taskbar Notification Area-Dateien\1ptrans(1).gif) |
|