如何解决消息过滤器指示应用程序正忙. (来自HRESULT的异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER))asp.net mvc [英] how to solve The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) asp.net mvc
问题描述
我在Visual Studio 2010中运行了代码.发布应用程序时,它可以正常工作.
I ran my code in Visual Studio 2010. It works fine when I publish my application.
在Windows Server 2003 IIS6.0中,出现异常.
In Windows Server 2003 IIS6.0 I get an exception.
消息过滤器指示应用程序正忙. (来自HRESULT的异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER))asp.net mvc
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 nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref isvisible,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, 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 nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref encoded, ref nullobj,
ref nullobj, ref encodending, ref nullobj);
doc.Close(ref ofalse, ref nullobj, ref nullobj);
wordApplication.Quit(ref nullobj, 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正在显示一个对话框.使其可见,以便您可以看到对话框.
You will probably find that Word is showing a dialog box. Make it visible so that you can see what the dialog is.
wordApp.DisplayAlerts := wdAlertsNone;
还将有助于取消警告对话框
will also help suppress warning dialogs
doc.Saved = true;
将阻止它在关闭文档时提示您保存更改.
will stop it from prompting you to save changes when you close the document.
这篇关于如何解决消息过滤器指示应用程序正忙. (来自HRESULT的异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER))asp.net mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!