小妹我用winform开发个项目碰见个难题,望各位高手帮忙解答下
我想用webBrowser 控件编辑html 就写了以下代码webBrowser1.Navigate("about:blank");
webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "On", null);
我装的是vs2005 在我机器上一切正常,可是在别的机器上运行(已经装了framework2.0)就报
未将对象引用实例的错误,我仔细一找发现就是在SetValue(webBrowser1.Document.DomDocument, "On", null);这句代码引发的
小妹急啊,望各位老鸟帮忙看看
谢谢!

解决方案 »

  1.   

    试试
    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
      webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "On", null);
    }
      

  2.   

    不行啊,好像还是不认啊,装了vs2005的可以,只装framework2.0就不行啊
    这到底是啥原因啊
      

  3.   

    是否需要在IIS里面改点东西?例如web服务扩展等...或者把安装的framework2.0重新注册一下
      

  4.   

    private void MakeAnEditableBrowser()
            {
                web1.Navigate(@"about:blank");
                mshtml.HTMLDocument hDoc = (mshtml.HTMLDocument)web1.Document.DomDocument;
                hDoc.designMode = "On";        }需要引用MSHTML这个COM组件
      

  5.   

    小女子真的很急啊! 回复人:ki1381() ( 二级(初级)) 信誉:100
    需要引用MSHTML这个COM组件
      

  6.   

    看那台机子是否装了.net 1.1 或别的,把其他的都删掉,或重新装遍.net2.0
      

  7.   

    webBrowser1.Navigate和Get/SetValue不能连续调用的。
    Navigate是异步过程,返回的时候DomDocument更本就没有完全生成,接下来的调用用到DomDocument当然就有问题了。试试看把Navigate方到别的地方,等确定页面下载完毕以后再调用Get/SetValue。最正确的做法是在DocumentComplete事件以后。孟子已经是钻石级王老五了...
      

  8.   

    别的机器没有webBrowser组件。
    发布时要打包进去。
      

  9.   

    我是来看
    webBrowser控件

    小女子
    有什么关系滴
      

  10.   

    webBrowser1.Document.ExecCommand("editmode",true,webBrowser1);//使webBrowser1处于编辑状态
      

  11.   

    webBrowser1.Navigate("about:blank");
    while(webBrowser1.Document == null && webBrowser1.Document.DomDocument == null)
    {
      Application.DoEvents();
    }
    webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "On", null);
      

  12.   

    webBrowser1.Document.ExecCommand("editmode",true,webBrowser1);//使webBrowser1处于编辑状态
      

  13.   

    需要引用MSHTML这个COM组件
    你装VS2005会自动装上framework2.0,是不是你的IIS没有配置好
      

  14.   

    加上这个引用
    using System.Security.Permissions;再在命名空间namespace { 
    和类定义public partial class Form1 : Form
    之间加上
    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    [System.Runtime.InteropServices.ComVisibleAttribute(true)]
    试试