Cefsharp3-WinForms x64 显示空白页但 x86 工作
Cefsharp3-WinForms x64 shows blank page but x86 works
我在初始化 CefSharp3 时遇到问题。控件在初始化后给出一个空白页。
我遵循 CefSharp Wiki 页面的说明 (https://github.com/cefsharp/CefSharp/wiki/Quick-Start and http://ourcodeworld.com/articles/read/173/how-to-use-cefsharp-chromium-embedded-framework-csharp-in-a-winforms-application)
问题是,当我为 x64 构建应用程序时,我得到一个空白页面,但它在 x86 中工作正常。
我的 WinForms 项目中唯一的代码是这样的:
public ChromiumWebBrowser chromeBrowser;
public void InitializeChromium()
{
CefSettings settings = new CefSettings();
// Initialize cef with the provided settings
Cef.Initialize(settings);
// Create a browser component
chromeBrowser = new ChromiumWebBrowser("http://ourcodeworld.com");
// Add it to the form and fill it to the form window.
this.Controls.Add(chromeBrowser);
chromeBrowser.Dock = DockStyle.Fill;
}
public Form1()
{
InitializeComponent();
// Start the browser after initialize global component
InitializeChromium();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Cef.Shutdown();
}
我也尝试添加一个面板,并在面板中使用 panel1.Controls.Add(chromeBrowser)
而不是 this.Controls.add(chromeBrowser)
初始化 ChromiumBrowser,但问题仍然存在。
我在 CefSharp wiki 的故障排除部分找到了这个:
https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting
b) The developer tools. Add a button to your form and make a call to "browser.ShowDevTools()". If you can see a document has loaded and you have a DOM in there, then your problem is a display output one and your most likely problem is one of not setting 'Dock' correctly, or some other setting is causing the browser to render offscreen/headless. If you get a blank tool window, or no tool window at all, then CefSharp has failed to initialize correctly, so you have a set-up issue to troubleshoot.
这正是我遇到的症状。
我尝试在我的笔记本电脑(配备 Win7、VS2013 和 .NET 4.5.2 的 MacBook Pro)上创建相同的项目,并且效果非常好。这意味着我的工作站出现问题(win10、VS2015 .NET 4.5.3)。
有什么想法吗?
这似乎是最新版本中的错误。目前的解决方案是使用 v51.0.0 版本。
您可以在 VS2015 的 NuGet 包管理器中轻松完成此操作,或者如果您使用的是 VS2013,请在从包管理器命令行安装 cefsharp 时使用“--version 51.0.0”选项。
问题的问题在这里:
https://github.com/cefsharp/CefSharp/issues/1870
密切关注此问题以寻求未来的解决方案。
2016 年 11 月 28 日更新
这是 CefSharp 当前 V53 版本中的错误。它已得到 CefSharp 团队的确认,并在问题 #1819 (https://github.com/cefsharp/CefSharp/issues/1819)
中得到解决
BUG貌似修复了,但是要到V55才会发布
目前的解决方案是返回到 V51 或从 V55 的源代码构建您自己的版本。
我在初始化 CefSharp3 时遇到问题。控件在初始化后给出一个空白页。 我遵循 CefSharp Wiki 页面的说明 (https://github.com/cefsharp/CefSharp/wiki/Quick-Start and http://ourcodeworld.com/articles/read/173/how-to-use-cefsharp-chromium-embedded-framework-csharp-in-a-winforms-application) 问题是,当我为 x64 构建应用程序时,我得到一个空白页面,但它在 x86 中工作正常。
我的 WinForms 项目中唯一的代码是这样的:
public ChromiumWebBrowser chromeBrowser;
public void InitializeChromium()
{
CefSettings settings = new CefSettings();
// Initialize cef with the provided settings
Cef.Initialize(settings);
// Create a browser component
chromeBrowser = new ChromiumWebBrowser("http://ourcodeworld.com");
// Add it to the form and fill it to the form window.
this.Controls.Add(chromeBrowser);
chromeBrowser.Dock = DockStyle.Fill;
}
public Form1()
{
InitializeComponent();
// Start the browser after initialize global component
InitializeChromium();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Cef.Shutdown();
}
我也尝试添加一个面板,并在面板中使用 panel1.Controls.Add(chromeBrowser)
而不是 this.Controls.add(chromeBrowser)
初始化 ChromiumBrowser,但问题仍然存在。
我在 CefSharp wiki 的故障排除部分找到了这个:
https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting
b) The developer tools. Add a button to your form and make a call to "browser.ShowDevTools()". If you can see a document has loaded and you have a DOM in there, then your problem is a display output one and your most likely problem is one of not setting 'Dock' correctly, or some other setting is causing the browser to render offscreen/headless. If you get a blank tool window, or no tool window at all, then CefSharp has failed to initialize correctly, so you have a set-up issue to troubleshoot.
这正是我遇到的症状。
我尝试在我的笔记本电脑(配备 Win7、VS2013 和 .NET 4.5.2 的 MacBook Pro)上创建相同的项目,并且效果非常好。这意味着我的工作站出现问题(win10、VS2015 .NET 4.5.3)。
有什么想法吗?
这似乎是最新版本中的错误。目前的解决方案是使用 v51.0.0 版本。
您可以在 VS2015 的 NuGet 包管理器中轻松完成此操作,或者如果您使用的是 VS2013,请在从包管理器命令行安装 cefsharp 时使用“--version 51.0.0”选项。
问题的问题在这里: https://github.com/cefsharp/CefSharp/issues/1870
密切关注此问题以寻求未来的解决方案。
2016 年 11 月 28 日更新
这是 CefSharp 当前 V53 版本中的错误。它已得到 CefSharp 团队的确认,并在问题 #1819 (https://github.com/cefsharp/CefSharp/issues/1819)
中得到解决BUG貌似修复了,但是要到V55才会发布
目前的解决方案是返回到 V51 或从 V55 的源代码构建您自己的版本。