Word Automation from IIS

怎甘沉沦 提交于 2019-11-30 09:52:48

问题


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.

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:

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

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

  • Enable 32-Bit Applications: True
  • Load User Profile: True

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

Edit: 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.


回答1:


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.

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).



来源:https://stackoverflow.com/questions/28174208/word-automation-from-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!