在Asp.net中打开Word文档时出错 [英] Error When Opening Word Document in Asp.net

查看:123
本文介绍了在Asp.net中打开Word文档时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用此命令在Windows窗体中打开Word文档时出现以下错误:

I get the following error when I attempt to open a word doc in windows forms using this command:

object missing = System.Reflection.Missing.Value;
Word.Application wordApp = new Word.Application();
Microsoft.Office.Interop.Word.Document aDoc = null;
aDoc = wordApp.Documents.Open(ref oFileName, ref oMissing, ref otrueValue,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,                ref oMissing, ref oMissing, ref oMissing); 



错误消息是:试图读取或写入受保护的内存.这通常表明其他内存已损坏."

我正在使用VS 2008 SP1. C#中的.net Framework 3.5 SP1编码

我正在使用Word 2003 sp3.并且具有以下using语句:

使用Microsoft.Office.Interop.Word;
使用Word = Microsoft.Office.Interop.Word;

这可以在家用PC上运行,但是在工作PC上开发时出现错误.

我是否缺少一些打开单词文档等的权利"或. . . ?

提前谢谢.

Kishore R



The error msg is: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

I am using VS 2008 SP1. .net framework 3.5 sp1 coding in c#

I am using word 2003 sp 3. and have the following using statements:

using Microsoft.Office.Interop.Word;
using Word = Microsoft.Office.Interop.Word;

This works on my home PC but I get the error when developing on the work PC.

Am I missing some "rights" to be able to open word docs, etc. or . . . ?

Thanks in advance.

Kishore R

推荐答案

绝对不建议这样在服务器上打开Word文档.

您正在尝试在IIS ASP.net辅助进程中打开Word(本机应用程序).

重新考虑您要做什么.
It is absolutely unadvised to open Word documents on the server like this.

You are trying to open Word (native application) inside IIS ASP.net worker process.

Rethink what you are trying to do.


转到Project->属性->构建标签
并将Platform Targer更改为" x86 ".

再次运行代码.
go to Project --> properties --> Build Tab
and change the Platform Targer to "x86".

run the code again.


这篇关于在Asp.net中打开Word文档时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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