微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

初始化C#的geckoWebBrowser异常

我的程序如下引发异常.

Program.cs如下:

static void Main()
    {
        Gecko.@R_502[email protected]("D:\\xulrunner\\");
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());

    }

Form1.cs如下:

private void Form1_Load(object sender,EventArgs e)
    {
        //Gecko.@R_502[email protected]("D:\\xulrunner\\");

        geckoWebbrowser1.Navigate("http://www.google.com");

    }

翻译自中文,例外情况如下:

“System .__ ComObject”无法转换接口类型“Gecko.nsIWebNavigation”

以下代码中抛出异常:

public ChromeContext()
{
    using (var appShallSvc = @R_502[email protected]<nsIAppShellService>(Contracts.AppShellService))
    {
        webNav = appShallSvc.Instance.Createwindowlessbrowser(true).AsComPtr(); //this is where the exception is thrown

        webNav.Instance.LoadURI("chrome://global/content/alerts/alert.xul",null,null);

    }

}

任何帮助将不胜感激.

解决方法

对于旧版本,您需要将GeckoFX版本与xulrunner的完全正确版本相匹配.

在这里查看您的版本:https://bitbucket.org/geckofx/geckofx/wiki/Version_lists

在这里下载xulrunner:https://releases.mozilla.org/pub/xulrunner/releases/

但是版本45.0大大简化了这一点:

For Geckofx 45.0 and newer publishing has been moved to a nuget package model,which includes the both the geckofx files and the required firefox files.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐