2010-09-20 63 views
0

我試圖從.Net網絡應用程序打開一個Word文檔。 (簡述)的代碼包含...在測試服務器上自動執行Word的錯誤

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

,並實際創建文件的代碼包括:

object oMissing = System.Reflection.Missing.Value; 
object oEndOfDoc = "\\endofdoc"; // \endofdoc is a predefined bookmark 
object oTemplate = WebConfigurationManager.AppSettings["GuidelineRepsTemplate"]; //this points to a .doc I am using as a template 

//Start Word and create a new document. 
    Word._Application oWord; 
    Word._Document oDoc; 
    oWord = new Word.Application(); 
    oWord.Visible = true; 
    oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing); 

    object oBookMark = "Representative"; 
    oDoc.Bookmarks.get_Item(ref oBookMark).Range.Text = lblRecipient.Text; 

    object oBookMark1 = "Guidelines"; 
    oDoc.Bookmarks.get_Item(ref oBookMark1).Range.Text = Guidelines.ToString(); 

object fileName = WebConfigurationManager.AppSettings["GuidelineRepsPath"] + ContactID.ToString() + "\\" + fileString2 + ".doc"; 
     object FileFormat = Word.WdSaveFormat.wdFormatDocument; 
     oDoc.SaveAs(ref fileName, ref FileFormat, 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, ref oMissing); 

我作爲模板使用Word文檔中有和我兩個書籤在上面的代碼中填充這些書籤。

在我的開發盒上它一切正常。該文檔在Word中打開,用戶可以根據需要進行更改,並將其保存在我爲其創建的目錄中(目錄代碼未在上面顯示)。

當我發佈到測試服務器 - 每次運行它的時候我得到這個錯誤:

The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) 

堆棧跟蹤不能讓它的頭腦什麼是錯的 - 一個例子是:

[COMException (0x8001010a): The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))] 
Microsoft.Office.Interop.Word.DocumentClass.get_Bookmarks() +0 
SendConfirmEmailReps.CreateDocs(Int32 ContactID, Int32 OrganisationID) +942 
SendConfirmEmailReps.Page_Load(Object sender, EventArgs e) +317 
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 
System.Web.UI.Control.OnLoad(EventArgs e) +99 
System.Web.UI.Control.LoadRecursive() +50 
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627 

這表明書籤有問題。所以我參考了書籤,並開始使用名爲Hello.doc的文件作爲我的模板。沒有書籤 - 只有「hello」這個詞。

這也下降了 - 但StackTrace表明它是在調用SaveAs時。

所以,問題是......爲什麼它在我的開發盒上工作,而不是在服務器上。服務器上安裝了Word。

+0

可能是因爲防病毒還是窗口DEP? – VinayC 2010-09-20 13:09:46

回答

0

我認爲這是Microsoft Office自動化的服務器端無人值守使用中固有的穩定性問題。詳細描述如下here

相關問題