Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CefSharp ChromiumWebBrowser will initialize and load the page passed to the constructor, but calling MyBrowser.Load("URL") returns a blank screen

If I pass a website into the browser constructor like:

ChromiumWebBrowser MyBrowser = new ChromiumWebBrowser("www.google.com");

Google will load. However, after initializing the browser, calling

MyBrowser.Load("Example.com");

Gives a blank screen. I have events tied to FrameLoadEnd, which fire when google finishes loading, but don't fire at all after the call to Load, which means that the webpages are not even being loaded offscreen.

I've spent a long time working on the issue but I can't find a solution. I've downloaded the packages through NuGet, installed VC 2012 Redistributable, initialized CefSettings, switched to x86, etc. I'm not sure what I'm doing wrong other than possibly misunderstanding the way this method is meant to be used. It's also possible that I'm not copying the right files to my output directory, but I do have CopyLocal = True on all of my references.

It might be important to note that my browsers are implemented programatticaly, as opposed to being dragged and dropped into the WinForms Designer. This is pretty necessary for my code, as I have a large number of browsers sort of crawling the web and showing pages to the user, hence the need for a reliable load method.

Here is a sample of my debug.log from my release folder, edited to remove too many duplicates:

[0826/130205:WARNING:resource_bundle.cc(304)] locale_file_path.empty()
...
[0826/131439:WARNING:resource_bundle.cc(304)] locale_file_path.empty()
[0826/134434:ERROR:renderer_main.cc(212)] Running without renderer sandbox
...
[0826/135650:ERROR:renderer_main.cc(212)] Running without renderer sandbox
[0826/135658:ERROR:ipc_channel_win.cc(136)] pipe error: 109
[0826/135921:ERROR:renderer_main.cc(212)] Running without renderer sandbox
...
[0826/135921:ERROR:renderer_main.cc(212)] Running without renderer sandbox
[0826/135933:ERROR:ipc_channel_win.cc(378)] pipe error: 109
[0826/135933:ERROR:ipc_channel_win.cc(412)] pipe error: 232
[0826/140141:ERROR:renderer_main.cc(212)] Running without renderer sandbox
...
[0826/140141:ERROR:renderer_main.cc(212)] Running without renderer sandbox
[0826/140148:ERROR:ipc_channel_win.cc(412)] pipe error: 232
like image 761
bakester14 Avatar asked Feb 09 '23 05:02

bakester14


1 Answers

Unfortunately Load fails silently if the browser isn't initialized. The next version is a major rewrite, which will throw an exception, so you'll know immediately what's going on. If you hook the IsBrowserInitializedChanged event you should be able to safely call Load after it fires.

https://github.com/cefsharp/CefSharp/blob/cefsharp/41/CefSharp.WinForms/ChromiumWebBrowser.cs#L233

The current version as at writing is 41.0.1. Next version will be 43.0.0 (There is already a -pre release on nuget.org, though it's not quite ready for prime time yet)

like image 179
amaitland Avatar answered Feb 12 '23 10:02

amaitland