IIS中的Word自动化 [英] Word Automation from IIS

查看:116
本文介绍了IIS中的Word自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Windows应用程序,该应用程序使用C#启动Word进程(Microsoft.Office.Interopt.Word).我加载了两个插件word.AddIns.Add(@"C:\ temp \ addin.dot",true);.这段代码在我的Windows应用程序中运行良好.

I created a Windows application which starts a Word process (Microsoft.Office.Interopt.Word) with C#. I load two addins word.AddIns.Add(@"C:\temp\addin.dot", true);. This code works perfectly fine within my windows application.

为了能够远程启动此过程,我创建了一个MVC Web应用程序.该Web应用程序使用相同的代码,但在加载插件的那部分失败:

To be able to start this process remotly, I created a MVC web application. The web app uses the same code, but it failes on the part where I load the addins:

错误: Word无法打开此文档模板:(C:\ temp \ addin.dot)

error: Word cannot open this document template: (C:\temp\addin.dot)

Web应用程序使用具有管理员权限和以下设置的应用程序池:

The web application uses an application pool with administrator permissions and following settings:

  • 启用32位应用程序:True
  • 加载用户个人资料:True

有人知道这个问题可能是什么吗?为什么相同的代码在Web服务器上的行为会有所不同?

Does anyone have an idea what the problem could be? Why does the same code behave differently on the web server?

任务管理器向我显示单词处理是从正确的用户帐户开始的.启动Windows应用程序时,它与我使用的帐户相同.

The task manager shows me that the word process gets started with the correct user account. It is the same account as I use, when I start the windows application.

推荐答案

Web服务器并非旨在运行用户应用程序.由于您使用的是COM引用,因此该库要求该应用程序正在运行以执行操作.

Web servers aren't meant to run user applications. Since you're using a COM reference, the library requires the application to be running to perform manipulations.

如果您希望自动化文档的生成/读取,我的建议是使用像DocX这样的库.这样一来,您就可以直接使用文件格式本身,而无需引入COM引用(互操作库).

If you're looking to automate document generation/reading, my advise would be to use a library like DocX. This would enable you to work directly with the file format itself without bringing in COM references (the interop libraries).

这篇关于IIS中的Word自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆