Reputation: 1038
I have a web app running locally at http://localhost:3000/. I started with the CefSharp.MinimalExample.WinForms
project, pointed it to this URL and the app starts up successfully. My next step was to test out the C# <-> JS bridge to see how those calls work.
I followed the How do you expose a .NET class to Javascript? documentation and have the .NET side set up to have a class that can be called by JavaScript. The next step is to call CefSharp.BindObjectAsync
in JavaScript to initiate the binding, but on my site CefSharp
is undefined on the JavaScript side. The error in chrome I receive Uncaught (in promise) ReferenceError: CefSharp is not defined
. My understanding of CefSharp is that it will bind the appropriate CefSharp methods to the window object so that it can be accessed from the JS side. Will this not work if I'm accessing a remote site that isn't included in the actual .NET project? It seems like I'm missing something stupidly simple, but after a few passes through the docs I am still stuck.
Upvotes: 1
Views: 664
Reputation: 1038
I had copied pieces of my Program.cs from this file. I misunderstood the purpose of BrowserSubprocessPath
and left it in there. After removing that setting I can get to the CefSharp
object in JS. My guess is that this setting was initializing the CefSharp object in the wrong place.
Doc on BrowserSubprocessPath:
// The path to a separate executable that will be launched for sub-processes. By
// default the browser process executable is used. See the comments on Cef.ExecuteProcess()
// for details. Also configurable using the "browser-subprocess-path" command-line
// switch. Default is CefSharp.BrowserSubprocess.exe
Upvotes: 0