none
The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A RRS feed

  • Question

  • Dear All,

    I am working on a web application in which I need to create a word file using Microsoft.Office.Interop.Word.

    When I run the application in desgin mode debugging, I can create a word file.

    The problem is when hosted my application into local IIS (Version 5.1), I am getting the following error.

    Server Error in '/yapSMS' Application.


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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.InteropServices.COMException: The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

    Here my code is,

                object nullobj = System.Reflection.Missing.Value;
               
    object oMissing = System.Reflection.Missing.Value;
               
    object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
               
    //Start Word and create a new document.
               
    Microsoft.Office.Interop.Word._Application oWord;
               
    Microsoft.Office.Interop.Word._Document oDoc;
                oWord
    = new Microsoft.Office.Interop.Word.Application();
                oWord
    .Visible = true;
                oDoc
    = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
               
    //Insert a paragraph at the beginning of the document.
               
    Microsoft.Office.Interop.Word.Paragraph oPara1;
                oPara1
    = oDoc.Content.Paragraphs.Add(ref oMissing);
               
    foreach (RepeaterItem ri in Repeater1.Items)
               
    {
                   
    Label lbl = (Label)ri.FindControl("ltrlForm");
                   
    Literal ltr = (Literal)ri.FindControl("ltrlComment");
                   
    string tst = StripHtml(ltr.Text, false);
                   
    string tst1 = Server.HtmlEncode(ltr.Text.ToString());
                   
    string newstr = ltr.Text.Replace("<BR>", "~");
                   
    string[] htmlstr = newstr.Split('~');
                    oPara1
    .Range.Text = lbl.Text;
                    oPara1
    .Range.Font.Bold = 1;
                    oPara1
    .Range.Font.Size = 14;
                    oPara1
    .Range.Font.Name = "Cambria";
                    oPara1
    .Format.SpaceAfter = 6;    //24 pt spacing after paragraph.
                    oPara1
    .Range.InsertParagraphAfter();
                   
    Microsoft.Office.Interop.Word.Paragraph oPara2;
                   
    object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    oPara2
    = oDoc.Content.Paragraphs.Add(ref oRng);
                    oPara2
    .Range.Font.Size = 10;
                    oPara2
    .Range.Font.Bold = 0;
                    oPara2
    .Range.Font.Name = "Verdana";
                   
    if (htmlstr.Length > 1)
                   
    {
                       
    for (int i = 0; i < htmlstr.Length; i++)
                       
    {
                            oPara2
    .Range.Text = StripHtml(htmlstr[i].ToString(), false);
                            oPara2
    .Range.InsertParagraphAfter();
                            oPara2
    .Range.Font.Name = "Verdana";
                            oPara2
    .Range.Font.Size = 10;
                            oPara2
    .Range.Font.Bold = 0;
                       
    }
                   
    }
                   
    else
                   
    {
                        oPara2
    .Range.Text = tst.ToString();
                        oPara2
    .Range.InsertParagraphAfter();
                        oPara2
    .Range.Font.Name = "Verdana";
                        oPara2
    .Range.Font.Size = 10;
                        oPara2
    .Range.Font.Bold = 0;
                   
    }
                    oPara2
    .Range.Font.Bold = 0;
                    oPara2
    .Range.Font.Size = 10;
                    oPara2
    .Format.SpaceAfter = 30;
               
    }
                oWord
    .Quit(ref nullobj, ref nullobj, ref nullobj);

    Thanks in advance.

    Saturday, July 9, 2011 10:45 AM

Answers

  • Thanks Cindy Meister.

    As it was too late of my project to be completed, I tried another way. I tried using Stringbuilder and created the word file using filestream.

    StringBuilder strBuilder = new StringBuilder();
    string strPath = Request.PhysicalApplicationPath + "\\Documents\\Task-List.doc";
    FileStream fStream = File.Create(strPath);
    fStream.Close();
    StreamWriter sWriter = new StreamWriter(strPath);
    sWriter.Write(strBuilder);
    sWriter.Close();
    


    Anyway thanks. Thank You so much for ur reply and suggestions.

    Tuesday, July 12, 2011 11:22 AM

All replies

  • Dear All,

    I am working on asp.net 3.5.

    In my application, i am creating a word file using the below code.

    object nullobj = System.Reflection.Missing.Value;
        object oMissing = System.Reflection.Missing.Value;
        object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
        //Start Word and create a new document.
        Microsoft.Office.Interop.Word._Application oWord;
        Microsoft.Office.Interop.Word._Document oDoc;
        oWord = new Microsoft.Office.Interop.Word.Application();
        oWord.Visible = true;
        oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
        //Insert a paragraph at the beginning of the document.
        Microsoft.Office.Interop.Word.Paragraph oPara1;
        oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
        foreach (RepeaterItem ri in Repeater1.Items)
        {
          Label lbl = (Label)ri.FindControl("ltrlForm");
          Literal ltr = (Literal)ri.FindControl("ltrlComment");
          string tst = StripHtml(ltr.Text, false);
          string tst1 = Server.HtmlEncode(ltr.Text.ToString());
          string newstr = ltr.Text.Replace("<BR>", "~");
          string[] htmlstr = newstr.Split('~');
          oPara1.Range.Text = lbl.Text;
          oPara1.Range.Font.Bold = 1;
          oPara1.Range.Font.Size = 14;
          oPara1.Range.Font.Name = "Cambria";
          oPara1.Format.SpaceAfter = 6;  //24 pt spacing after paragraph.
          oPara1.Range.InsertParagraphAfter();
          Microsoft.Office.Interop.Word.Paragraph oPara2;
          object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
          oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
          oPara2.Range.Font.Size = 10;
          oPara2.Range.Font.Bold = 0;
          oPara2.Range.Font.Name = "Verdana";
          if (htmlstr.Length > 1)
          {
            for (int i = 0; i < htmlstr.Length; i++)
            {
              oPara2.Range.Text = StripHtml(htmlstr[i].ToString(), false);
              oPara2.Range.InsertParagraphAfter();
              oPara2.Range.Font.Name = "Verdana";
              oPara2.Range.Font.Size = 10;
              oPara2.Range.Font.Bold = 0;
            }
          }
          else
          {
            oPara2.Range.Text = tst.ToString();
            oPara2.Range.InsertParagraphAfter();
            oPara2.Range.Font.Name = "Verdana";
            oPara2.Range.Font.Size = 10;
            oPara2.Range.Font.Bold = 0;
          }
          oPara2.Range.Font.Bold = 0;
          oPara2.Range.Font.Size = 10;
          oPara2.Format.SpaceAfter = 30;
        }
        

    When I run the application from the VS, its working fine and word file is generating.

    When I host the site in my Local IIS, its not working. I am getting error message.

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

    Can anyone help me.

    Thanks in advance.

     

    • Merged by Lie You Friday, July 15, 2011 2:42 AM word and ASP.Net related, and resolved in this forum
    Friday, July 8, 2011 12:52 PM
  • Hi,

    There is a thread with same issue

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/c11ffffd-0385-40f7-b32f-77077de87617/


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
    Friday, July 8, 2011 1:27 PM
  • Dear All,

    I am working on asp.net 3.5 Web Application.

    In my application, i am creating a word file from Gridview using the below code.

    object nullobj = System.Reflection.Missing.Value;
      object oMissing = System.Reflection.Missing.Value;
      object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
      //Start Word and create a new document.
      Microsoft.Office.Interop.Word._Application oWord;
      Microsoft.Office.Interop.Word._Document oDoc;
      oWord = new Microsoft.Office.Interop.Word.Application();
      oWord.Visible = true;
      oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
      //Insert a paragraph at the beginning of the document.
      Microsoft.Office.Interop.Word.Paragraph oPara1;
      oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
      foreach (RepeaterItem ri in Repeater1.Items)
      {
       Label lbl = (Label)ri.FindControl("ltrlForm");
       Literal ltr = (Literal)ri.FindControl("ltrlComment");
       string tst = StripHtml(ltr.Text, false);
       string tst1 = Server.HtmlEncode(ltr.Text.ToString());
       string newstr = ltr.Text.Replace("
    ", "~"); string[] htmlstr = newstr.Split('~'); oPara1.Range.Text = lbl.Text; oPara1.Range.Font.Bold = 1; oPara1.Range.Font.Size = 14; oPara1.Range.Font.Name = "Cambria"; oPara1.Format.SpaceAfter = 6; //24 pt spacing after paragraph. oPara1.Range.InsertParagraphAfter(); Microsoft.Office.Interop.Word.Paragraph oPara2; object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; oPara2 = oDoc.Content.Paragraphs.Add(ref oRng); oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; oPara2.Range.Font.Name = "Verdana"; if (htmlstr.Length > 1) { for (int i = 0; i < htmlstr.Length; i++) { oPara2.Range.Text = StripHtml(htmlstr[i].ToString(), false); oPara2.Range.InsertParagraphAfter(); oPara2.Range.Font.Name = "Verdana"; oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; } } else { oPara2.Range.Text = tst.ToString(); oPara2.Range.InsertParagraphAfter(); oPara2.Range.Font.Name = "Verdana"; oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; } oPara2.Range.Font.Bold = 0; oPara2.Range.Font.Size = 10; oPara2.Format.SpaceAfter = 30; }

    When I run the application from the VS, its working fine and word file is generating.

    When I host the site in my Local IIS, its not working. I am getting error message.

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

    Can anyone help me.

    Thanks in advance.

    Saturday, July 9, 2011 5:06 AM
  • Hi,

    There is a thread with same issue

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/c11ffffd-0385-40f7-b32f-77077de87617/


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    I could not find solution from the above thread. I am using web application.

    Can u guide me little more.

    Thank you.

    Saturday, July 9, 2011 7:45 AM
  • and which line of code is causing the error? If you don't know and the stack trace doesn't tell you, put in some debugging.

    FWIW this kind of use of the Office applications is not recommened. They're designed for user interaction, not automation server-side. You might want to look at this KB article: 

    http://support.microsoft.com/kb/257757/en-us

     

    The Office Open XML file formats were created for exactly this kind of requirement: creating documents in a server environment. You might want to look at the information on OpenXMLDeveloper.org and use that approach.


    Cindy Meister, VSTO/Word MVP
    Saturday, July 9, 2011 2:04 PM
    Moderator
  • and which line of code is causing the error? If you don't know and the stack trace doesn't tell you, put in some debugging.

    I am getting error on,

     Microsoft.Office.Interop.Word.Paragraph oPara1;
     oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
    
    


    Tuesday, July 12, 2011 4:27 AM
  • Hello Shekhar_m,

    Welcome to the MSDN Forum.

    For ASP.Net issue, we can post it to the following more appropriate forums for more efficient responses:

                    ASP.NET Forums : The Official Microsoft ASP.NET Forums

    For Word issue, I suggest you to post this issue to the ASP.Net Forums for more help. Here is the link:

                    Visual Studio Tools for Office Forum       

    Also we need to know this forum:

                    Forums : The Official Microsoft IIS Site

    And here is some search result s in MSDN for your reference:

                    Word VSTO - Application is busy exception!!

                    problem when showing a window.

    Hope it helps.


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 12, 2011 6:04 AM
  • It's possible that the Document object to which the paragraph should be added is not in a state to allow the action. There are various things you could try, such as building a loop and querying Documents.Count until it's > 0, but...

    I do have to wonder if the application is showing a message and waiting for user response. The error message you're seeing indicates that may be the case. Are you able to view the Word application to check that? If yes, how about if you comment out the rest of your code from that point on, then try to work in the document as an end-user? Is that possible?

    You may also want to inquire about this in an asp.net forum as there may be security protocols or something that you need to implement when automating Word from somewhere other than the local machine (look up DCOM, for starters).


    Cindy Meister, VSTO/Word MVP
    Tuesday, July 12, 2011 6:51 AM
    Moderator
  • Thanks Cindy Meister.

    As it was too late of my project to be completed, I tried another way. I tried using Stringbuilder and created the word file using filestream.

    StringBuilder strBuilder = new StringBuilder();
    string strPath = Request.PhysicalApplicationPath + "\\Documents\\Task-List.doc";
    FileStream fStream = File.Create(strPath);
    fStream.Close();
    StreamWriter sWriter = new StreamWriter(strPath);
    sWriter.Write(strBuilder);
    sWriter.Close();
    


    Anyway thanks. Thank You so much for ur reply and suggestions.

    Tuesday, July 12, 2011 11:22 AM