我只是想使用我的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