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
If you use EvaluateScriptAsync, the script will be executed asynchronously and the method returns a Task encapsulating the response from the script. Create a Windows Forms Application.
Add below the method for receiving data from a web application and bind it to the CefSharp eventhandler called "JavascriptMessageReceived". Whenever the data has been sent from a web application, then this method will be triggered.
The method is used to execute the simple javascript code. In the javascript code, attach the "CefSharp.PostMessage" handler with "messageSentEvent " type. Whenever the event is dispatched with the type "messageSentEvent " in the web application then "CefSharp.PostMessage" will be executed.
The same URL has been given in the CefSharp browser control (See the code part in point #5 of the WinForm application). Run the Winform application. In the WinForm application, type a message in the text box and click send button. The ReactJS application (inside the browser control) will receive the message.
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;
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With