微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc – 如何解决消息过滤器表明应用程序正忙. (来自HRESULT的异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER))asp.net mvc

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


   }

解决方法

您可能会发现Word正在显示一个对话框.使其可见,以便您可以看到对话框是什么.

wordApp.displayAlerts := wDalertsNone;

还将有助于抑制警告对话框

doc.Saved = true;

将阻止它在关闭文档时提示您保存更改.

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

相关推荐