简体   繁体   中英

CefSharp WinForms - browser control freezing when loading local html file

I've got a winforms app with the ChromiumWebBrowser control, and I've got it working for every external site I've checked. However, when I try to load html from a local .html file, the browser control freezes up and isn't usable. I can't click links or use textboxes, and even the context menu doesn't work on this control.

The control isn't broken as such - I can still load a new URL and won't have any issues. I should point out that the page does load fully, as I've got something in place to pull the full HTML from the page when it loads, but I cannot interact with it.

Is there a reason that this could happen? I've tried using

browser.Load(filepath);

and

string html = File.ReadAllText(path);
browser.LoadHtml(html, "https://test");

Both of these will load the page but neither of them will let me use it. I assumed that CefSharp would support loading local files, was I wrong?

Locking up the UI thread? Try this on a backgroundworker:

Invoke(new Action(() => browser.Load(filepath)));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM