在我的计算机上并没有抛出异常,只是第二次显示为空.
估计异常是mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)this.axWebBrowser1.Document; 没有转换成功,详细的正在研究中.

解决方案 »

  1.   

    如果你想解决就用一个public bool flag=true;
    在一个BUTTON的CLICK事件中加如下代码:
    if(flag==true)
    button1.enable=false;
    这样你就不会再按button了!
      

  2.   

    问题是我需要再按button,让函数多次执行:)
      

  3.   

    异常并没有抛出,只是我跟踪axWebBrowser1时看到了异常Message,现象也是第二次显示为空
      

  4.   

    你不应该在执行完Navigate命令后立即取Document属性,因为这时候Document可能还没有准备好。
    改成这样:
    private void button1_Click(object sender, System.EventArgs e)
    {
      Object nothing = null;
      this.axWebBrowser1.Navigate("about:blank", ref nothing, ref nothing, ref nothing, ref nothing);
    }private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
    {
    object obj=this.axWebBrowser1.Document;
    mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)this.axWebBrowser1.Document;

    doc.clear();
    doc.write("<html><head><title></title></head><body>idiotwei</body></html>");
    }
    //ok
      

  5.   

    这样你不管Navigate about:blank 还是http://www.sina.com.cn都不会出错。