4

My program below throws an exception.

Program.cs is as follows:

    static void Main()
    {
        Gecko.Xpcom.Initialize("D:\\xulrunner\\");
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());

    }

Form1.cs is as follows:

    private void Form1_Load(object sender, EventArgs e)
    {
        //Gecko.Xpcom.Initialize("D:\\xulrunner\\");

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

    }

Translated from Chinese, the exception is as follows:

"System.__ComObject" cannot convert Interface type "Gecko.nsIWebNavigation"

The exception is thrown in the following code:

public ChromeContext()
{
    using (var appShallSvc = Xpcom.GetService2<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", 0, null, null, null);

    }

}

Any help will be appreciated.

WonderWorker
  • 8,539
  • 4
  • 63
  • 74
W F
  • 41
  • 5

1 Answers1

0

For older versions, you need to match your GeckoFX release with the exact correct version of xulrunner.

Check your version here: https://bitbucket.org/geckofx/geckofx/wiki/Version_lists

Download xulrunner here: https://releases.mozilla.org/pub/xulrunner/releases/

But this has been greatly simplified with version 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.

Sire
  • 4,086
  • 4
  • 39
  • 74