Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net-mvc

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");


   }
like image 223
sandy barasker Avatar asked Jul 29 '11 11:07

sandy barasker


1 Answers

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.

like image 136
Frank Avatar answered Nov 15 '22 04:11

Frank