我在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"); }
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。