/// <summary> /// Initialize the chrome browser with the html file to be opened /// </summary> private void InitializeChromium() { // Check if the page exists string page = string.Format(@"{0}\html-resources\dist\index.html", Application.StartupPath); if (!File.Exists(page)) { MessageBox.Show("Error html file doesn't exist : " + page); } CefSettings settings = new CefSettings(); // Initialize cef with the provided settings settings.CefCommandLineArgs.Add("disable-gpu", "1"); settings.BrowserSubprocessPath = @"x86\CefSharp.BrowserSubprocess.exe"; Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); // Create a browser component chromeBrowser = new ChromiumWebBrowser(page); // Add it to the form and fill it to the form window. this.Controls.Add(chromeBrowser); chromeBrowser.Dock = DockStyle.Fill; chromeBrowser.BringToFront(); CefSharpSettings.LegacyJavascriptBindingEnabled = true; // Initialize the interaction variable _comparisonInter = new ComparisonJSInteraction(this); // Register C# objects chromeBrowser.RegisterAsyncJsObject("chromeDebugger", new ChromeDebugger(chromeBrowser, this)); chromeBrowser.RegisterAsyncJsObject("comparisonJSInteraction", _comparisonInter); }
/// <summary> /// Initialize the chrome browser with the html file to be opened /// </summary> private void InitializeChromium() { try { // Check if the page exists string page = string.Format(@"{0}\html-resources\dist\index.html", Application.StartupPath); if (!File.Exists(page)) { MessageBox.Show("Error html file doesn't exist : " + page, Utils.AssemblyProduct, MessageBoxButtons.OK, MessageBoxIcon.Error); } CefSettings settings = new CefSettings(); // Initialize cef with the provided settings settings.CefCommandLineArgs.Add("disable-gpu", "1"); settings.BrowserSubprocessPath = @"x86\CefSharp.BrowserSubprocess.exe"; //settings.BrowserSubprocessPath = string.Format(@"{0}\x86\CefSharp.BrowserSubprocess.exe", Application.StartupPath); ; Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); // Create a browser component chromeBrowser = new ChromiumWebBrowser(page); // Add it to the form and fill it to the form window. this.Controls.Add(chromeBrowser); chromeBrowser.Dock = DockStyle.Fill; chromeBrowser.BringToFront(); CefSharpSettings.LegacyJavascriptBindingEnabled = true; // Initialize the interaction variable _comparisonInter = new ComparisonJSInteraction(this); // Register C# objects chromeBrowser.RegisterAsyncJsObject("chromeDebugger", new ChromeDebugger(chromeBrowser, this)); chromeBrowser.RegisterAsyncJsObject("comparisonJSInteraction", _comparisonInter); } catch (FileNotFoundException) { MessageBox.Show("FileNotFoundException in InitializeChromium().\n\nPlease try to install C++ Redistributable Packages for Visual Studio x86, min version www.microsoft.com/download/details.aspx?id=40784", Utils.AssemblyProduct, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exc) { MessageBox.Show(exc.Message, Utils.AssemblyProduct, MessageBoxButtons.OK, MessageBoxIcon.Error); } }