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

在WinForms应用中使用ChromiumWebBrowser控件加载本地.html文件时出现浏览器冻结,无法交互的问题。已知页面加载完成,但链接、文本框及右键菜单均不可用。尝试了Load和LoadHtml方法均未成功。讨论中提到可能的原因包括UI线程锁定,并提供了解决方案:在后台线程中调用Load方法避免阻塞UI。
摘要由CSDN通过智能技术生成

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?

Talk1:

It does support loading local files, there are many options to choose from. Read the general usage guide on the wiki for more details. LoadHtml works fine for me in version 55 and there have been no other reports of problems from upgrading users.

Talk2:

same problem. with a regular url. page is displayed but basically frozen. whats the solution?

Talk3:

sorry. my bad. was using e.Frame.GetSourceAsync.Result. Bad Idea.

Solutions1

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值