简体   繁体   中英

GeckoFX JSContext not found C#

Im trying to inject javascript into my GeckoFX Browser by using the following code..

GeckoWebBrowser browser = ....;
using (AutoJSContext context = new AutoJSContext(browser.JSContext))
{                               
   string result;
   context.EvaluateScript("3 + 2;", out result)
}

From another SO post found here: How Can Execute Javascript Commands via GeckoFX

But I get an error:

'Gecko.GeckoWebBrowser' does not contain a definition for 'JSContext' and no extension method 'JSContext' accepting a first argument of type 'Gecko.GeckoWebBrowser' could be found(are you missing a using directive or an assembly reference?)

Fairly new to C# and Im not quite sure what Im missing? Ive been searching and troubleshooting for hours and have not found a solution as to what Im overlooking and or missing. Would greatly appreciate if someone shined some light on this. Thanks!!

It appears that in version 22, the JSContext has been moved down a level, to the Window.

So now you'll want

using (AutoJSContext context = new AutoJSContext(browser.Window.JSContext))

I found this in the new unit tests .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM