我在Visual Studio 2010中运行了我的代码.当我发布我的应用程序时它工作正常.
在Windows Server 2003 IIS6.0中,我得到一个例外.
The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) asp.net mvc
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 isvisible,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 encoded,ref encodending,ref nullobj); doc.Close(ref ofalse,ref nullobj); wordApplication.Quit(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"); }