asp.net读写word文档,在vs2008调试运行的时候是正常的,在iis中运行报页面打开失败,
网上查的dcomcnfg配置也都改了,请教如何解决?操作系统是xp

解决方案 »

  1.   

    在web.config里面加上下面一行就可以了:
    <identity impersonate="true" userName="administrator" password="password" />
    但是这样相当于把
    administrator用户口令写在配置文件里面了,这样肯定是不好的,
    有其他更好的办法没有?
      

  2.   

    目录操作权限,domcnfg权限
    <identity impersonate="true" userName="administrator" password="password" />
    模拟用户
    错误详细信息
      

  3.   

    我直接用这个的using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    using Microsoft.Office.Interop.Word;public partial class jbxx_0101 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { 
            //Label1.Text = Doc2Text(Request.QueryString["docFileName"].ToString());
            //Label1.Text = Doc2Text("aa");
            ////Response.ClearContent();
            ////Response.ClearHeaders();
            ////Response.ContentType = "Application/msword";
            ////string s = Server.MapPath("aa.doc");
            ////Response.WriteFile("aa.doc");
            ////Response.Write(s);
            ////Response.Flush();
            ////Response.Close();
            #region a
        //    ApplicationClass app = null;
        //    Document doc = null;
        //    object missing = System.Reflection.Missing.Value;
        //    object FileName = Server.MapPath("编制说明.rtf");//@"E:\学习试验项目\ReadFromWordDoc\test.doc"; 
        //    object readOnly = true;
        //    object isVisible = false;
        //    try
        //    {
        //        app = new ApplicationClass();
        //        doc = app.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 isVisible, ref missing,
        //            ref missing, ref missing, ref missing);
        //        string textString = doc.Content.Text;
        //        Label1.Text = textString;
        //        //Response.Write(textString);
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}
        ////获得word文件的文本内容
        //public string Doc2Text(string docFileName)
        //{
        //    //实例化COM
        //    Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
        //    object fileobj = docFileName;
        //    object nullobj = System.Reflection.Missing.Value;
        //    //打开指定文件(不同版本的COM参数个数有差异,一般而言除第一个外都用nullobj就行了)
        //    Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref nullobj,
        //        ref nullobj, ref nullobj, ref nullobj,
        //        ref nullobj, ref nullobj, ref nullobj,
        //        ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj
        //        );
        //    //取得doc文件中的文本
        //    string outText = doc.Content.Text;
        //    //关闭文件
        //    doc.Close(ref nullobj, ref nullobj, ref nullobj);
        //    //关闭COM
        //    wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
        //    //返回
        //    return outText;
            #endregion
        }
    }