C# COM 办公自动化 - RPC_E_SYS_CALL_FAILED

发布于 2024-07-05 19:37:17 字数 508 浏览 6 评论 0原文

我正在编写一个充当 PowerPoint 2007 插件的 C# 程序。 在某些计算机上,对 PowerPoint 对象模型的某些调用会抛出 COMException 以及消息 RPC_E_SYS_CALL_FAILED。 我找不到任何关于如何处理此错误或如何避免它的具体建议。 从谷歌搜索来看,它看起来像是与消息队列或单线程公寓有关。 还是我离得远了?

错误消息的示例是:

系统调用失败。 (HRESULT 异常:0x80010100 (RPC_E_SYS_CALL_FAILED))
在 Microsoft.Office.Interop.PowerPoint._Presentation.get_FullName()

不幸的是,问题发生在客户端的计算机上,所以我没有简单的方法来调试它! 每当收到此错误时,我是否应该重试呼叫?

任何帮助我解决这个问题的建议将不胜感激!

I'm writing a C# program that acts as a PowerPoint 2007 plugin. On some machines, some calls to the PowerPoint object model throw a COMException with the message RPC_E_SYS_CALL_FAILED. I couldn't find any specific advice on what to do regarding this error, or how to avoid it. From Googling it looks like something to do with the message queue or Single-Threaded Apartments. Or am I way off?

Example of the error message is:

System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED))
at Microsoft.Office.Interop.PowerPoint._Presentation.get_FullName()

Unfortunately, the problem is occurring on a client's machine, so I have no easy way to debug it! Should I just retry the calls whenever I get this error?

Any advice to help me resolve this problem would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

肥爪爪 2024-07-12 19:37:17

我不知道这与您的问题有关,但您的所有 COM 调用都必须来自创建加载项的同一线程内。 如果您创建了新线程,则必须特别小心。 这两篇文章中描述了详细信息:

I don't know it is related to your problem, but all your COM calls must come from within the same thread your add-in was created on. If you created new threads you must take special care. Details are described in these two articles:

ゃ人海孤独症 2024-07-12 19:37:17

您是否从设置了 ApartmentState 的线程中进行调用? 如果不是,那可能是罪魁祸首 - COM 互操作对这类事情非常挑剔

are you making the call from a thread with its ApartmentState set? if not, that might be the culprit - COM interop is pretty finicky about that sort of thing

鹿! 2024-07-12 19:37:17

客户端的安全设置是什么? 客户端的安全设置(Windows/操作系统设置或 PowerPoint/应用程序设置)很可能不允许您的插件通过 RPC 进行通信。

What are the security settings of the client? It is quite possible that the security settings of the client (either Windows/OS settings or PowerPoint/App settings) won't allow your plug-in to communicate via RPC.

完美的未来在梦里 2024-07-12 19:37:17

如果您从后台线程对 Powerpoint 对象模型进行任何调用,则很容易发生这种情况。 一种可能的情况是有一个计时器定期检查某种状态值。 如果计时器启动时 Powerpoint 正忙(例如打开对话框),则呼叫将失败。

这篇 Microsoft 文章概述了 Office 中的线程支持:
http://msdn.microsoft.com/en-us/library/8sesy69e。 ASPX

This can very easily happen if you make any calls to the Powerpoint object model from a background thread. One plausible scenario is having a timer that periodically checks some sort of status value. If, when the timer fires, Powerpoint is busy (for example a dialog box is open) the call will fail.

This Microsoft article gives an overview of threading support in Office:
http://msdn.microsoft.com/en-us/library/8sesy69e.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文