//******上面的代码是生成word文档过程,一切很正常*********
object path = HttpContext.Current.Server.MapPath("../word/" + getFileName() + ".doc");
        word.ActiveDocument.SaveAs(ref path, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
        doc.Close(ref Nothing, ref Nothing, ref Nothing);
        word.Quit(ref Nothing, ref Nothing, ref Nothing);
        word = null;
        System.GC.Collect();
        return path.ToString();////////////////////////////////////////////
doc是Word.Document对象
word是Word.Application对象
在调用word.ActiveDocument.SaveAs时出错
错误信息:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 我在本机测试一切都很正常,放在服务器上就出错了,
希望高手帮忙!

解决方案 »

  1.   

    感觉是调用com的问题,我觉得最好的办法还是单独做个console exe exe里面调用word
    aspx 里调用该exe,这样应该不会出问题
      

  2.   

    服务器的word版本、你本机的word版本、还有网络上访问的word版本一样吗?
      

  3.   

    doc.Close(ref   Nothing,   ref   Nothing,   ref   Nothing); 
    这句去掉看
      

  4.   

    检查一下IIS,是否对目标目录没有权限?