Hello,
We have an application that is using CefSharp 1..
This application loads a Java Scriptfile using EvaluateScrip(...).
Later the application calls functions in the Java script library.
The application uses WPF and a CustomControl that wraps the WebView control.
The wrapper fakes a rectabgle for the designer and adds an IScrollInfo implementation.
This all works fine.
Now I am porting this to CefSharp 3.
I manged to create a UserControll and add the IScrollInfo functionality.
But I did not manage to call any Java script function.
Since we use a ScrollViewer I hide the CEF scrollbars. This is done with a Java script function:
@"document.documentElement.style.overflow = ""hidden"";"This works with CEFSharp 1 but not with CEFSharp 3
When calling ChromiumWebBrowser >> EvaluateScript(...) I get the error
There was no end point listening at net.pipe://localhost/CefSharpSubProcessProxy/10920/1 that could accept the message.
This is often caused by an incorrect address or SOAP action. For more details, see "InnerException", if it exists.
Inner Exception: The pipe end point net.pipe://localhost/CefSharpSubProcessProxy/10920/1 was not found on the local computer.
I added my code below.
I am not shure if I did miss something. Any Hint?
greetings
Clemens Hoffmann
public CefSharp3ControlWrapper()
{
InitializeComponent();
if (DesignerProperties.GetIsInDesignMode(this))
{
InDesignMode = true;
System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
rect.Fill = System.Windows.Media.Brushes.LightGray;
this.WebViewWrapper.Children.Add(rect);
Label text = new Label();
text.Content = "Cef Sharp Control";
text.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
text.VerticalAlignment = System.Windows.VerticalAlignment.Center;
this.WebViewWrapper.Children.Add(text);
}
else
{
this.InitializeCEF();
InDesignMode = false;
web = new ChromiumWebBrowser();
web.Name = "WebView";
web.FrameLoadEnd -= new EventHandler<CefSharp.FrameLoadEndEventArgs>(webView_LoadCompleted);
web.FrameLoadEnd += new EventHandler<CefSharp.FrameLoadEndEventArgs>(webView_LoadCompleted);
web.IsBrowserInitializedChanged -= new DependencyPropertyChangedEventHandler(webView_Initialized);
web.IsBrowserInitializedChanged += new DependencyPropertyChangedEventHandler(webView_Initialized);
web.SnapsToDevicePixels = true;
web.UseLayoutRounding = true;
web.Address = "about:blank";
this.WebViewWrapper.Children.Add(web);
this.LoadJavaScript = true;
}
}
/// <summary>
/// Before anything can be done with the web control we need to initialize the core
/// </summary>
private void InitializeCEF()
{
var settings = new CefSettings
{
BrowserSubprocessPath = "CefSharp.BrowserSubprocess.exe"
};
Cef.Initialize(settings);
}
/// <summary>
/// The browser is initialized. Inform components that wait for it.
/// </summary>
/// <param name="sender">The web view</param>
/// <param name="e">the changed event</param>
private void webView_Initialized(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.web.IsBrowserInitialized)
this.web.EvaluateScript(@"document.documentElement.style.overflow = ""hidden"";");
EventHandler evt = Volatile.Read(ref this.IsBrowserInitializedChanged);
if (evt != null)
evt(this, EventArgs.Empty);
}