2010-09-20 60 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

相关问题