An error message occurs when you are performing intensive OLE Automation in a loop in Visual C++: "The remote procedure call failed" (181894)
The information in this article applies to:
- Microsoft Visual C++ 2005 Express Edition
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++ 4.0
- Microsoft Office 97 for Windows
This article was previously published under Q181894 SYMPTOMS You are performing intensive OLE Automation, most likely in
a loop without user intervention, and receive the following error message: The remote procedure call failed.
CAUSE Every thread that uses COM or OLE must call the CoInitialize function
or the OleInitialize function, respectively. When this call is made, the OS creates a
hidden top-level window, owned by your thread, for implementation purposes.
Because the OS relies on Windows messaging behind-the-scenes, your thread
should, and in some cases MUST, pump messages. Failure to do so can result in
automation errors, and sometimes in a deadlock situation when another
application broadcasts a message to all top-level windows (for example, an
application might broadcast a WM_WININICHANGE or WM_SETTINGCHANGE message to
notify other applications the default printer has changed).RESOLUTION If you are using OLE Automation in a loop (for example,
writing out 10,000 rows of data to Microsoft Excel), you need a PeekMessage
loop inside your loop so that messages will get processed.STATUS This behavior is by design.REFERENCES Microsoft Visual C++ online for PeekMessage
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
136885
OLE threads must dispatch messages
Modification Type: | Major | Last Reviewed: | 1/7/2006 |
---|
Keywords: | kbtshoot kbAutomation kberrmsg kbprb kbThread KB181894 kbAudDeveloper |
---|
|