加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 如何解决消息过滤器表明应用程序正忙. (来自HRES

发布时间:2020-12-16 03:52:16 所属栏目:asp.Net 来源:网络整理
导读:我在Visual Studio 2010中运行了我的代码.当我发布我的应用程序时它工作正常. 在Windows Server 2003 IIS6.0中,我得到一个例外. The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYL
我在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;

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读