3

I'm new here hoping for some help with geckoFX in C#

So I just downloaded the geckoFX and did the following.

  1. Downloaded: geckofx.dll

  2. downloaded: XULRunner

I added the geckofx browser successfully and works fine but when I try to run this code to add JavaScript to the page I get an error.

The error I'm getting is: skybound.geckoFX.AutoJSContext does not contain a definition for evaluate script and jscontext.

Also I don't know if this helps but AutoJSContext and EvaluateScript are not hightlighting.

Here is my code

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Skybound.Gecko;


namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Skybound.Gecko.Xpcom.Initialize(@"C:\Program Files\xulrunner");
    }

    private void geckoWebBrowser1_DocumentCompleted(object sender, EventArgs e)
    {
        string outString = "";
        using (AutoJSContext java = new AutoJSContext(geckoWebBrowser1.Window.JSContext))
        {
            java.EvaluateScript(@"window.alert('alert')", out outString);
        }
    }
}
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Leslie Jones
  • 540
  • 2
  • 9
  • 22
  • What version of geckofx are you using? I'm guessing, based on the namespaces you are using, its an old one... – Tom Aug 09 '14 at 17:24
  • its the most current. – Leslie Jones Aug 09 '14 at 21:05
  • Are you sure? Skybound no longer appear in the namespace. ? http://bitbucket.org/geckofx/geckofx-29.0/downloads – Tom Aug 09 '14 at 23:01
  • Hi Tom, thanks for the quick response, much appreciated. Your right I wasn't using the correct version. I downloaded it but its not working for me. The first thing I did was added geckofx-core and geckofx-webforms to my references which worked fine. I tried adding Gecko.Xpcom.Initialize("C:\\myproject\\xulrunner"); ,the project failed to run when i debugged it i got the error (Unable to find an entry point named 'NS_StringContainerInit' in DLL 'xul'.) do you know what that might be? are there any sample projects using geckofx 29? – Leslie Jones Aug 10 '14 at 01:30
  • https://bitbucket.org/geckofx/geckofx/wiki/Version_lists and the source code contains a sample/test project. – Tom Aug 10 '14 at 05:06
  • hey, you should go back over all your questions that were answered and accept the best answer...it's just good SO etiquette ;-) – whyoz Feb 26 '15 at 02:25

1 Answers1

2

You should call EvaluateScript like so:

java.EvaluateScript(@"window.alert('alert')", (nsISupports)geckoWebBrowser1.Window.DomWindow, out result);
dimitrisk
  • 774
  • 9
  • 15