刚上班就遇到一个郁闷的问题 高手指点下好吗?

生活 生活 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
以下这段代码 在vs运行条件下 可以通过,但是发布到本地机IIS上就会报错,
消息筛选器显示应用程序正在使用中。 (异常来自 HRESULT:0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Runtime.InteropServices.COMException: 消息筛选器显示应用程序正在使用中。 (异常来自 HRESULT:0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

行 56: ref missing, ref missing, ref missing);
行 57:
行 58: aDoc.PageSetup.PageHeight = 1050.0F;
行 59: aDoc.PageSetup.PageWidth = 710.0F;
行 60: aDoc.PageSetup.TopMargin = 5;

堆栈跟踪:


[COMException (0x8001010a): 消息筛选器显示应用程序正在使用中。 (异常来自 HRESULT:0x8001010A (RPC_E_SERVERCALL_RETRYLATER))]
Microsoft.Office.Interop.Word.DocumentClass.get_PageSetup() +0
MyFaxWin.MSearch.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\liten000\桌面\新建文件夹\MyFaxWin\MSearch.aspx.cs:58
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061



string path = "D:\11.doc"
protected void Page_Load(object sender, EventArgs e)
{

ExpertControl(this, path);

object fileName = path;
object read_only = false;
object visible = true;
object isFalse = false;

// the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;

//Open the document that was chosen by the dialog
ApplicationClass wordApp = new ApplicationClass();
wordApp.Visible = false;

Document aDoc = wordApp.Documents.Open(
ref fileName, ref missing, ref missing,
ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);

aDoc.PageSetup.PageHeight = 1050.0F;
aDoc.PageSetup.PageWidth = 710.0F;
aDoc.PageSetup.TopMargin = 5;
aDoc.PageSetup.BottomMargin = 20;
aDoc.PageSetup.LeftMargin = 90;
aDoc.PageSetup.RightMargin = 50;
aDoc.Save();
System.Diagnostics.Process.Start(@path);
Response.End();
}

public void ExpertControl(System.Web.UI.Control source, string File)
{
Response.ContentType = "application/ms-word";
Response.Charset = "utf-8";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
//关闭控件的视图状态
source.Page.EnableViewState = false;
//初始化HtmlWriter
System.IO.StringWriter writer = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);
source.RenderControl(htmlWriter);
StreamWriter streamwriter = new StreamWriter(File); //创建数据流

streamwriter.Write(writer.ToString()); //输出
streamwriter.Close(); //关闭流

}

...全文
评论 21
收藏 已收藏
分享
返回顶部
生活
C# 111,129 成员 642,540 内容