且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正确处理在C#中的COM互操作对象特别是MS Office应用程序

更新时间:2023-02-07 23:37:47

根据办公室的你控制通过互操作,并在服务器上发生的情况下,是的,你可能需要做一些认真的回旋得到的版本摆脱了Office应用程序的运行实例的。有未经predictable(和不必要的)对话当中,例如,Word将打开的时候它不是交互(无的Office应用程序特别适用于无人参与的执行,因此建议,即使是最新的版本,他们没有安装服务器端使用)。

Depending on the version of Office you are controlling through interop, and the circumstances that occur on the server, yes, you may need to do some serious convolutions to get rid of a running instance of one of the Office applications. There are unpredictable (and unnecessary) dialogs which, for example, Word will open when it is not interactive (None of the Office applications are particularly well designed for unattended execution, thus the recommendation that even with the latest versions that they not be installed for server-side use).

有关服务器的情况下,可以考虑使用的Aspose的筹码,而不是办公室或其他的替代品。互动,本地使用的情况下,可能需要上一次额外轰轰烈烈的杀戮,因为办公自动化服务器特别顽劣的非托管对象。

For server cases, consider using Aspose's stack rather than Office, or another of the alternatives. The interactive, local use cases, you may need that "extra vigorous killing" on occasion since the Office automation servers are particularly badly behaved unmanaged objects.