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中,我得到一个例外.
我的代码在这里: 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; 将阻止它在关闭文档时提示您保存更改. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
推荐文章
站长推荐
- asp.net-mvc-3 – 列模板kendo ui grid mvc动作链
- 实体框架 – 使用实体框架数据模型添加验证属性
- asp.net-mvc – Mvc渲染动作/部分响应输出
- asp.net-mvc-3 – 以下部分已定义,但尚未为布局页
- asp.net – 使用Thinktecture Identity Server 2
- 实现对Asp.NetMvc及Asp.NetCore的权限控制
- asp.net-core – 在ASP.NET 5 MVC6中使用什么而不
- asp.net – 如何绑定一个MemoryStream到asp:图像
- asp.net-mvc – asp.net mvc – 整数字段的可选/
- asp.net-mvc – MetadataTypeAttribute在DNX Cor
热点阅读