2

我正在使用 Interop word ApplicationClass.Documents.Open 方法打开一个 word 文档。在我的应用程序中,当我使用以下语句时,它会挂起: IE 显示它仍在加载,但它从不做任何事情。

_Document aDoc = WordApp.Documents.Open(
    ref fileName, ref oMissing, ref readOnly, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing);

我通过创建一个虚拟网站尝试了同样的事情,并且成功了。问题是它只是没有在我的应用程序中打开 word 文档。这段代码有什么问题,还是我需要添加更多内容?

我还看到了一个创建和执行的线程,但不知道它的起源。

4

1 回答 1

0

我可以从您的问题中了解到,您正在尝试使用 Web 服务器上的 Word 应用程序本身(通过 COM 互操作)打开一个 Word 文档。

你不应该这样做。Word 不是为了在 Windows 服务的上下文中运行而创建的。也就是说,没有用户界面。

可能 Word 正在对话框中等待用户的某些响应。但由于您没有 UI,因此不会显示。

于 2010-11-03T16:12:37.663 回答