这期内容当中小编将会给大家带来有关openwebkitsharp出现COM对象与其基础RCW分开后就不能再使用的示例分析,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、雅安服务器托管、营销软件、网站建设、易县网站维护、网站推广。
Open-Webkit-Sharp实验:
private void button1_Click(object sender, EventArgs e)
{
webKitBrowser.UseJavaScript = true;
webKitBrowser.Navigate("http://localhost/index.html");
webKitBrowser.ShowJavaScriptAlertPanel += webKitBrowser_ShowJavaScriptAlertPanel;
webKitBrowser.DocumentCompleted += webKitBrowser_DocumentCompleted;
}
void webKitBrowser_ShowJavaScriptAlertPanel(object sender, WebKit.ShowJavaScriptAlertPanelEventArgs e)
{
//MessageBox.Show("msg:" + e.Message);//最好不要在这个事件中show,否则容易混乱出错
MessageBox.Show(e.Message);
Console.WriteLine(sender.ToString() + ":"+e.Message);
}
private void webKitBrowser_Load(object sender, EventArgs e)
{
webKitBrowser.GetScriptManager.ScriptObject = this;
}
private void button2_Click(object sender, EventArgs e)
{
//string strScript = "messageBox(document.getElementById(\"testelement\").innerText = \"123456\")";
//webKitBrowser.StringByEvaluatingJavaScriptFromString(strScript);
WebKit.JSCore.JSValue V = webKitBrowser.GetScriptManager.CallFunction("test", new object[] { "zs", "addrr" });
//Console.WriteLine("jsvalue=" + V.ToString());
this.Text = webKitBrowser.DocumentTitle;
}
private void button3_Click(object sender, EventArgs e)
{
webKitBrowser.Navigate("http://www.taobao.com");//("http://www.pudn.com/Download/item/id/4061758.html"); //("https://www.baidu.com");
}先点button1(以便启用script),再点button3,然后关闭程序主窗体,就出现:COM 对象与其基础 RCW 分开后就不能再使用
网上有相应分析,其实说白了,就是C#中没有相应处理COM中相关资源,想来想去,我添加将事件去掉代码:
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
webKitBrowser.ShowJavaScriptAlertPanel -= webKitBrowser_ShowJavaScriptAlertPanel;
webKitBrowser.DocumentCompleted -= webKitBrowser_DocumentCompleted;
}
然后一切都OK了。
上述就是小编为大家分享的openwebkitsharp出现COM对象与其基础RCW分开后就不能再使用的示例分析了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。
网页标题:openwebkitsharp出现COM对象与其基础RCW分开后就不能再使用的示例分析
本文路径:http://www.jxjierui.cn/article/igsioi.html


咨询
建站咨询
