在wpf中使用 ChromiumWebBrowser ,版本是49来嵌套一个网页,升级到65版本之后发现嵌套的网页都变空白了,不知道哪里出了问题
初始化的执行代码:
if (!CefSharp.Cef.IsInitialized)
{
var settings = new CefSettings() { RemoteDebuggingPort = 8088 };
{
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
var CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache");
};
settings.Locale = "zh-CN";
settings.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.2; zh-CN) AppleWebKit/533+ (KHTML, like Gecko)";
settings.CefCommandLineArgs.Add("enable-media-stream", "1");
settings.CefCommandLineArgs.Add("disable-gpu", "1"); // 禁用gpu
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
}
this.webView = new ChromiumWebBrowser();
WebWindow.Children.Add(webView);
webView.SetValue(Grid.ColumnProperty, 0);
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
CefSharpSettings.LegacyJavascriptBindingEnabled = true;
this.helper.DownloadingFile += Helper_OnDownloadFile;
//将c#对象注册为 js对象
webView.RegisterAsyncJsObject("test", helper, new CefSharp.BindingOptions { CamelCaseJavascriptNames = false });
this.webView.Address = "网站地址";