Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
550 views
in Technique[技术] by (71.8m points)

c# - Word Automation from IIS

I created a Windows application which starts a Word process (Microsoft.Office.Interopt.Word) with C#. I load two addins word.AddIns.Add(@"C:empaddin.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:empaddin.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...