问题描述:
Windows Server® 2008 R2 x64
Office2010
IIS7.5
Browser发送请求给Server,Server查询数据库并把数据写入到.doc的模板中,然后把文件返回给Browser。直接运行VS程序运行正常。但是一旦通过IIS来访问请求的话,就报错。
System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00020906-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))
解决思路:
因为IIS用户没有操作Word组件的权限。
解决办法:
1. 在IIS中修改应用程序的Identity为LocalSystem
2.在DCOM Config中,把Microsoft Word的操作权限给IIS用户
首先,解决在DCOM Config中找不到Microsoft Word组件的问题:
On 64 bit system with 32 bit Office try this:
Start
Run
mmc -32
File
Add Remove Snap-in
Component Services
Add
OK
Console Root
Component Services
Computers
My Computer
DCOM Config
Microsoft Excel Application
...
其次,解决一个系统bug:
Windows 2008 Server x64
Please make this folder.
C:\Windows\SysWOW64\config\systemprofile\Desktop
Windows 2008 Server x86Please make this folder.
C:\Windows\System32\config\systemprofile\Desktop
3.把文件夹的操作权限给IIS用户
用了2天的时间,搞定!
参考文件:
http://forums.asp.net/t/931005.aspx/2/10