我只是想使用我的web应用程序从Word文件中读取文本。它在我的本地系统中运行良好,并且在我将其托管在服务器中之后,word文件不会打开,并且其抛出的null异常。在C中打开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
发布异常详细信息:消息,类型,堆栈跟踪,抛出异常的代码行。 –
这不是解决你的问题,但我认为你应该使用'Path.Combine(...)'而不是'BO.Misc.Settings.AttachementPathRelative + fileName'' System.IO.Path.Combine(BO.Misc.Settings .AttachementPathRelative,fileName)'。 'Path.Combine(..)'更健壮。 – mortb
@defaultlocale我已更新我的问题,你现在可以检查吗? – shanish