小妹我用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);这句代码引发的
小妹急啊,望各位老鸟帮忙看看
谢谢!
我想用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);这句代码引发的
小妹急啊,望各位老鸟帮忙看看
谢谢!
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "On", null);
}
这到底是啥原因啊
{
web1.Navigate(@"about:blank");
mshtml.HTMLDocument hDoc = (mshtml.HTMLDocument)web1.Document.DomDocument;
hDoc.designMode = "On"; }需要引用MSHTML这个COM组件
需要引用MSHTML这个COM组件
Navigate是异步过程,返回的时候DomDocument更本就没有完全生成,接下来的调用用到DomDocument当然就有问题了。试试看把Navigate方到别的地方,等确定页面下载完毕以后再调用Get/SetValue。最正确的做法是在DocumentComplete事件以后。孟子已经是钻石级王老五了...
发布时要打包进去。
webBrowser控件
和
小女子
有什么关系滴
while(webBrowser1.Document == null && webBrowser1.Document.DomDocument == null)
{
Application.DoEvents();
}
webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "On", null);
你装VS2005会自动装上framework2.0,是不是你的IIS没有配置好
using System.Security.Permissions;再在命名空间namespace {
和类定义public partial class Form1 : Form
之间加上
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
试试