Documents.Open returns ASP.NET windows 服务器 2012 R2 中的单词 Documents.Open returns 为空

Word Documents.Open returns null in ASP.NET windows server 2012 R2

我有一个 Web 应用程序,可以将一些信息初始化为 word 文件(使用文本格式)。

当 visual studio 运行 它时,它目前可以工作,但是当我在 IIS 中发布它和 运行 时,intrupt.word return 在打开的文档中为空。

我找到了一些解决方案,但这不适用于 windows server 2012 R2 一些解决方案,例如将启动用户更改为交互式用户或在 C:\Windows\SysWOW64\config\systemprofile 路径中创建 "Desktop" 目录或 C:\Windows\System32\config\systemprofile 路径所有此解决方案都适用于 windows server 2008 及更早版本,但不适用于 windows server 2012 R2

我找到了自己的解决方案

起初我使用中断来处理 word,但它对 web(不像 win App)应用程序不好搜索后我罚款 Aspose 有完整的 Word 处理方法并且它与 web 应用程序兼容。

使用 XML 库(如 ClosedXml)代替 Word Interop。

它不能通过 IIS 工作的最可能原因是因为根据 https://support.microsoft.com/en-us/kb/257757

不支持 Office 的服务器端自动化

我找到了自己的解决方案 我按照 Jeremy Thompson 所说的去做 起初我使用中断来处理 word,但它对 web 应用程序不利(不像 win App),在搜索后我罚款 Aspose 有完整的 Word 处理方法并且它与 web 应用程序兼容。