how to solve The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) asp.net mvc

6

I ran my code in Visual Studio 2010. It works fine when I publish my application.

In Windows Server 2003 IIS6.0 I get an exception.

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

My code is here:

         public ActionResult Getfile(int id)
          {
           Candidate candidate = IcandidateRepository.GetCandidate(id);

        if (candidate.FilePath != null)
        {
            string Filename = Path.GetFileName(candidate.FilePath);
            //string[] filename = candidate.FilePath.Split('\\');
            //foreach (var file in filename)
            //{
            //    Filename = file;
            //}

            Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();
            object nullobj = System.Reflection.Missing.Value;
            object filepath = candidate.FilePath;
            object ofalse = false;
            object isvisible = false;
            Microsoft.Office.Interop.Word.Document doc = wordApplication.Documents.Open(ref filepath,
            ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
            ref nullobj, ref  nullobj, ref nullobj, ref nullobj, ref isvisible,
            ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
            wordApplication.Visible = false;
            string newfilename = Filename.Replace(".doc", ".html");
            object onewfilename = @"D:\\clg\\" + newfilename;
            object encoded = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
            object encodending = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
            object oformat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
            doc.SaveAs(ref onewfilename, ref oformat, ref nullobj,
                        ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
                        ref nullobj, ref nullobj, ref encoded, ref nullobj,
                        ref nullobj, ref encodending, ref nullobj);
            doc.Close(ref ofalse, ref nullobj, ref nullobj);

            wordApplication.Quit(ref nullobj, ref nullobj, ref nullobj);
            string newfile = onewfilename.ToString();





            if (Filename != null)
            {
                dynamic cmd = System.Diagnostics.Process.Start(newfile);

                return RedirectToAction("CandidateDetails", new { id = candidate.CandidateID });

            }
        }


        return View("FileNotFound");


   }
asp.net-mvc
asked on Stack Overflow Jul 29, 2011 by sandy barasker • edited Feb 20, 2014 by Sai Kalyan Kumar Akshinthala

1 Answer

3

You will probably find that Word is showing a dialog box. Make it visible so that you can see what the dialog is.

    wordApp.DisplayAlerts := wdAlertsNone;

will also help suppress warning dialogs

    doc.Saved = true;

will stop it from prompting you to save changes when you close the document.

answered on Stack Overflow Aug 5, 2011 by Frank

User contributions licensed under CC BY-SA 3.0