код формы Код | using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using CefSharp; using CefSharp.WinForms; using System.Runtime.InteropServices;
namespace WhaBot_chrom { public partial class Form1 : Form { public ChromiumWebBrowser chromeBrowser; public Form1() { InitializeComponent(); InitializeChromium();
chromeBrowser.IsBrowserInitializedChanged += (sender, args) => { if (chromeBrowser.IsBrowserInitialized) { CefSharpSettings.LegacyJavascriptBindingEnabled = true; CefSharpSettings.WcfEnabled = true; chromeBrowser.JavascriptObjectRepository.Register("dev_form_class", new DevForm_class(chromeBrowser, this), isAsync: false); } }; }
private void Form1_Load(object sender, EventArgs e) { chromeBrowser.ShowDevTools(); } public void InitializeChromium() { CefSettings settings = new CefSettings(); // Initialize cef with the provided settings String page = string.Format(@"{0}\htmlres\test.html", Application.StartupPath); if (!File.Exists(page)) { MessageBox.Show("Error The html file doesn't exists : " + page); } // Initialize cef with the provided settings Cef.Initialize(settings);
chromeBrowser = new ChromiumWebBrowser(page); // Add it to the form and fill it to the form window. this.Controls.Add(chromeBrowser); chromeBrowser.Dock = DockStyle.Fill;
BrowserSettings browserSettings = new BrowserSettings(); browserSettings.FileAccessFromFileUrls = CefState.Enabled; browserSettings.UniversalAccessFromFileUrls = CefState.Enabled; chromeBrowser.BrowserSettings = browserSettings; }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { Cef.Shutdown(); } } }
|
империческим путем до меня приходит понимание что проблема в этом месте Код | chromeBrowser.IsBrowserInitializedChanged += (sender, args) => { if (chromeBrowser.IsBrowserInitialized) { CefSharpSettings.LegacyJavascriptBindingEnabled = true; CefSharpSettings.WcfEnabled = true; chromeBrowser.JavascriptObjectRepository.Register("dev_form_class", new DevForm_class(chromeBrowser, this), isAsync: false); // chromeBrowser.ExecuteJavaScriptAsync("alert('All Resources Have Loaded');"); } };
|
есть вот такая ошибка Цитата | "WhaBot_chrom.exe" (CLR v4.0.30319: WhaBot_chrom.exe). Загружено "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_ru_b77a5c561934e089\mscorlib.resources.dll". Сборка модуля выполнена без символов. Необработанное исключение: System.Exception: The ChromiumWebBrowser instance creates the underlying Chromium Embedded Framework (CEF) browser instance in an async fashion. The undelying CefBrowser instance is not yet initialized. Use the IsBrowserInitializedChanged event and check the IsBrowserInitialized property to determine when the browser has been initialized.
|
помогите с решением((( Это сообщение отредактировал(а) nezabor - 19.4.2020, 09:10
--------------------
Бесплатно о сайтах
|