How to decide. The message filter showed that the application was busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) asp.net mvc

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

In Windows Server 2003 IIS6.0, an exception is thrown.

The message filter showed that the application was 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"); } 
+6
source share
1 answer

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

  wordApp.DisplayAlerts := wdAlertsNone; 

also helps suppress alert dialogs

  doc.Saved = true; 

stops it by prompting you to save the changes when you close the document.

+3
source

Source: https://habr.com/ru/post/893857/


All Articles