摘要:通过引用Microsoft.Office.Interop.Word处理word文档,读取里面table的内容并将word转换为HTML
服务器环境描述:
实验用服务器(简称A):Windows XP SP2;Office 2003 繁体中文版;VS2008
部署服务器(简称B):Windows Server 2003; Office 2003 繁体中文版;VS2008
问题描述:
在A上部署后,一切功能正常;
然后在B上部署,出现如下错误:
Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
补充:1.服务器上IIS设置OK,但Application Pool我不确定,关于Identity中“Application Pool identity”我选择的是Configuration, user name和password是采用的一个administrator帐号。
2.在B上通过事件查看器发现有提示:Is authenticated? False
3.我有重装系统,重装office(A就是为了做实验才弄的)
4.server是部门server,只有部门成员才可以访问,其中leader具有administrator权限,在DCOM中和Application Pool中都是采用的一个leader的帐号密码。
5.主要源码如下:
//Upload1是一个支持多文件上传的控件
if(Upload1.UploadedFile.Count>0)
{
foreach(UploadedFile validFile in Uploaded1.UploadedFiles)
{
//无论是采用_Application或是ApplicationClass均是这个错误,不用讨论接口与类的问题。
Microsoft.Office.Interop.Word.ApplicationClass cls=new Microsoft.Office.Interop.ApplicationClass();
}
}
这个问题已经困扰我3天,恳请帮助。