通过 IIS 7 使用 Micorsoft.Office.Interop(对象库)读取 Word 文档时出错 [英] Error reading word doc using Micorsoft.Office.Interop(Object library) via IIS 7

查看:24
本文介绍了通过 IIS 7 使用 Micorsoft.Office.Interop(对象库)读取 Word 文档时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从 IIS 运行代码时读取文档时遇到问题.它没有读取文档并抛出错误尝试保存活动文档时没有打开文档.".

Iam facing issue while reading the document when runnning code from IIS. It is not reading the document and throwirng an error "No document is opne when trying to save the activedocument.".

 m_word.Documents.Open(ref FileName,
                                ref missing, ref readOnly, ref missing, ref missing,
                                ref missing, ref missing, ref missing, ref missing,
                                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);


 m_word.ActiveDocument.SaveAs2(ref FileName_rtf, ref FileFormat, ref missing1, ref missing1,
                    ref missing1, ref missing1, ref missing1, ref missing1,
                    ref missing1, ref missing1, ref missing1,
                    ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1);

m_word.ActiveDocument 从 IIS 运行时出错.它在 Visual Studio 调试模式下工作.

m_word.ActiveDocument is giving error when running from IIS. It is working in visual studio debugging mode.

我也试过下面的代码:

 Document doc_open =  m_word.Documents.Open(ref FileName,
                                ref missing, ref readOnly, ref missing, ref missing,
                                ref missing, ref missing, ref missing, ref missing,
                                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
            doc_open.Activate();

doc_open 正在返回 null,它在第二行抛出对象引用错误.这在代码处于调试模式时有效.在我们也有 IIS 7 和 MS 办公室的开发服务器上从 IIS 运行时发生错误.

doc_open is retruning null and it throws object reference error in the second line. this works when code is in debugging mode. Error occurs when ran from IIS on development server where we have IIS 7 and MS offices too.

推荐答案

添加:C:WindowsSysWOW64configsystemprofileDesktop

非常成功.

这篇关于通过 IIS 7 使用 Micorsoft.Office.Interop(对象库)读取 Word 文档时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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