我正在开发一个MVC Web应用程序,我需要在该应用程序中搜索网站。我试图使用CefGlue library。我需要使用网站的网址创建一个浏览器。但是,我得到的浏览器不包含任何框架,我没有收到任何错误:
CefRuntime.Load();
// Start the secondary CEF process.
var cefMainArgs = new CefMainArgs(new string[0]);
var cefApp = new PCefApp();
// This is where the code path divereges for child processes.
if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1)
{
Debug.WriteLine("CefRuntime could not the secondary process.");
}
// Settings for all of CEF (e.g. process management and control).
var cefSettings = new CefSettings
{
SingleProcess = false,
MultiThreadedMessageLoop = true
};
// Start the browser process (a child process).
CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero);
// Instruct CEF to not render to a window at all.
CefWindowInfo cefWindowInfo = CefWindowInfo.Create();
cefWindowInfo.SetAsWindowless(IntPtr.Zero, false);
// Settings for the browser window itself (e.g. should JavaScript be enabled?).
var cefBrowserSettings = new CefBrowserSettings();
// Initialize some the cust interactions with the browser process.
// The browser window will be 1280 x 720 (pixels).
var cefClient = new DemoCefClient(1280, 720);
// Start up the browser instance.
string url = "https://www.website.com";
var browser = CefBrowserHost.CreateBrowserSync(cefWindowInfo, cefClient, cefBrowserSettings, url);
Debug.WriteLine(browser.GetFrameNames().Count());
Runtime.Shutdown();
的代码开始
如果需要,我可以发布DemoCefRenderHandler
,DemoCefLoadHandler
,PCefApp
代码。
browser.GetFrameNames()。Count()返回0
感谢任何帮助