我只是想使用我的 Web 应用程序从 Word 文件中读取文本。它在我的本地系统中运行良好,在我将它托管在服务器中之后,word 文件没有打开,并且它抛出空异常。
这就是我正在做的,
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document WordDoc = new Microsoft.Office.Interop.Word.Document();
object DocNoParam = Type.Missing;
object DocReadOnly = false;
object DocVisible = false;
WordDoc = WordApp.Documents.Open(BO.Misc.Settings.AttachementPathRelative + fileName,
ref DocNoParam,
ref DocReadOnly,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocVisible,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam,
ref DocNoParam);
WordDoc.Activate();
我已经在服务器中安装了办公室,并且我也为我的 Web 应用程序提供了互操作的参考。我不知道为什么我会收到错误。有谁可以帮我离开这里吗。提前致谢。
我收到错误WordDoc.Activate()
,问题是我的系统中没有安装 Visual Studio,所以无法调试它。它给我一个例外说System.NullReferenceException: Object reference not set to an instance of an object.
堆栈跟踪是[NullReferenceException: Object reference not set to an instance of an object.]
Profile_CreateProfile.btnResumeUpload_Click(Object sender, EventArgs e) in d:\Apps\App1\Employee\AddEmployee.aspx.cs:411
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +153
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3690