user1322801
user1322801

Reputation: 849

CefSharp in WinForms - ExecuteScriptAsync or EvaluateScriptAsync doesnt work

I am using CefSharp WinForms in my project and i cannot get it to execute a JS script from the CefSharp Browser Control (I was to navigate to URLs though - so most of the CEF functionality works) I tried following the tutorial at: https://github.com/cefsharp/CefSharp/search?utf8=%E2%9C%93&q=BoundObject

I am using the following namespaces:

using CefSharp.WinForms;
using CefSharp.Internals;

and added references to the following assemblies (x64):

CefSharp.WinForms.dll
CefSharp.dll
CefSharp.Core.dll

but still I get the following error when I try to use one of the functions: ExecuteScriptAsync or EvaluateScriptAsync

I get the following error:

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

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

can anyone direct me to the point i am missing? is there another API? maybe some reference dll that I am missing? thanks

Upvotes: 6

Views: 5200

Answers (2)

Sam
Sam

Reputation: 109

CaptainBli is correct: you have to use "using CefSharp"

Probably you didn't expect it there, since it seems to be in another namespace: "CefSharp.WinForms.ChromiumWebBrowser".

This is because EvaluateScriptAsync and ExecuteScriptAsync are extension methods

Upvotes: 1

CaptainBli
CaptainBli

Reputation: 4201

You may be missing one other namespace. I would suggest you add:

 using CefSharp;

We were having the same trouble and found that we were simply missing this one. We now have:

using System.Text;
using CefSharp;
using CefSharp.WinForms;
using CefSharp.Internals;

Upvotes: 3

Related Questions