Winword RPC服务器不可用. (来自HRESULT的异常:0x800706BA) [英] Winword RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

查看:279
本文介绍了Winword RPC服务器不可用. (来自HRESULT的异常:0x800706BA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用C#开发的应用程序,我可以从列表框中打开Word文件,但是如果我关闭并再次重新打开同一文档,则会收到错误消息
RPC服务器不可用. (来自HRESULT的异常:0x800706BA)
我正在使用的代码如下

Hi, i have an app developed n C#, i am able to open the Word file from the list box but if i close and reopen the same document again i am getting the error
RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
the code i am using is below

private Word.ApplicationClass WordApp = new Word.ApplicationClass();

public void OpenDocument(object DocName)
       {
           try
           {

               WordApp.Visible = true;
               object optional = System.Type.Missing;
               object missing = System.Reflection.Missing.Value;
               object isVisible = true;
               Word.Document aDoc = WordApp.Documents.Open(ref DocName, ref       optional, ref optional,
                   ref optional, ref optional, ref optional, ref optional, ref optional, ref optional,
                   ref optional, ref optional, ref optional);
               aDoc.Activate();
           }

           catch (Exception e)
           {
               MessageBox.Show(e.Message);
           }
       }
private void listBox1_DoubleClick(object sender, EventArgs e)
       {
           try
           {
               string DocName;
               DocName = txtPath.Text.ToString();
               OpenDocument(DocName);
           }
           catch (Exception er1)
           {
               MessageBox.Show("" + er1.Message);
           }
       }

推荐答案

如果您自己关闭单词,则与您的应用程序创建的单词对象的连接将会丢失.重新打开Word文档时,它根本不是同一参考.该应用程序应创建一个新的Word应用程序,然后重新打开文档本身.

另外,请注意,当您使用应用程序创建的Word文档可见时,当用户与该Word实例进行交互时,可能会发生一些奇怪的错误.然后,您将无法控制它的可编程性.只需将其隐藏起来,直到完成操作,然后在再次使用它之前检查参考.

祝你好运!
If you closed word yourself, then the connection to the word object that your application created is lost. It is simply not the same reference when you reopen the word document. The application should create a new word application and reopen the document itself.

Also, be aware that when the word document that you created with your application is visible, some strange errors can occur when a user interacts with that word instance. You then lose control over it programmability. Simply keep it hidden until you are done and check the reference before using it again.

Good luck!


这个单词应用程序对象具有事件ApplicationEvents2_Event_Quit和ApplicationEvents2_Event_DocumentBeforeClose事件,我之前做过的事件为我自己设置了一个标志


我已在Word 2003上使用此解决方案

干杯
The word application objects have events ApplicationEvents2_Event_Quit & ApplicationEvents2_Event_DocumentBeforeClose events what I have done before is set a flag for myself


I have used this solution on Word 2003

Cheers


这篇关于Winword RPC服务器不可用. (来自HRESULT的异常:0x800706BA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆