简体   繁体   English

CefSharp WinForms-加载本地html文件时浏览器控件冻结

[英]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. 我有一个带有ChromiumWebBrowser控件的winforms应用程序,并且它已在我检查过的每个外部站点上正常运行。 However, when I try to load html from a local .html file, the browser control freezes up and isn't usable. 但是,当我尝试从本地.html文件加载html时,浏览器控件冻结,无法使用。 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. 控件本身并没有损坏-我仍然可以加载新的URL,并且不会出现任何问题。 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. 我应该指出,该页面确实可以完全加载,因为我有适当的位置可以在页面加载时从页面中提取完整的HTML,但是我无法与其进行交互。

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? 我以为CefSharp会支持加载本地文件,我错了吗?

Locking up the UI thread? 锁定UI线程? Try this on a backgroundworker: 在背景工作人员上尝试以下操作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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