M
M
myrkonianin2018-08-22 20:14:25
.NET
myrkonianin, 2018-08-22 20:14:25

CefSharp ERR_ABORTED, how to solve?

Unfortunately, I can’t throw the whole project, it weighs a lot for my 200kb / sec. But I can post Form1.cs.
The problem is, when the browser starts, everything works, except for the cef itself. Just a white screen where the page should be. Decided to throw event "LoadError" in MessageBox. writes "ERR_ABORTED". What to do?

Form1.cs
using System;
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;

namespace izziBrowser
{
    public partial class Form1 : Form
    {
        public ChromiumWebBrowser wb;
        public TabPage tpage;
        public int i = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            CefSettings cset = new CefSettings();
            Cef.Initialize(cset);
        
            newWebPage();
        }

        /*       private void newWebPage()
               {
                   wb = new ChromiumWebBrowser("https://ya.ru");
                   wb.Dock = DockStyle.Fill;
                   wb.Visible = true;

                   tabControl1.TabPages.Add("NewPage");
                   tabControl1.SelectTab(i);
                   tabControl1.SelectedTab.Controls.Add(wb);

                   i++;
               }*/

        private void newWebPage()
        {
            wb = new ChromiumWebBrowser("https://ya.ru");
            wb.Dock = DockStyle.Fill;
            wb.Visible = true;
            
            wb.LoadError += Wb_LoadError;
            wb.IsBrowserInitializedChanged += Wb_IsBrowserInitializedChanged;

            tpage = new TabPage("New Page");
            tabControl1.TabPages.Insert(i, tpage);
            tpage.Controls.Add(wb);
            
            tabControl1.SelectTab(i);
            /*
            tabControl1.TabPages.Add("NewPage");
            tabControl1.SelectTab(i);
            tabControl1.SelectedTab.Controls.Add(wb);
            */

            i++;
        }

        private void Wb_IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
        {
            if (e.IsBrowserInitialized)
            {
               wb.Load("www.ya.ru");

            }
        }

        private void Wb_LoadError(object sender, LoadErrorEventArgs e)
        {
            MessageBox.Show(e.ErrorText.ToString()); //Пишет ошибку "ERR_ABORTED"
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Cef.Shutdown();
        }

        private void tsAdd_Click(object sender, EventArgs e)
        {
            newWebPage();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ((ChromiumWebBrowser)tpage.Controls[0]).Back();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            ((ChromiumWebBrowser)tpage.Controls[0]).Forward();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            ((ChromiumWebBrowser)tpage.Controls[0]).Refresh();
        }

        private void tsUrl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Return") 
            {
                ((ChromiumWebBrowser)tpage.Controls[0]).Load(tsUrl.Text);
            } else if(e.KeyCode == Keys.Enter)
            {
                ((ChromiumWebBrowser)tpage.Controls[0]).Load(tsUrl.Text);
            }
        }

        private void tsClose_Click(object sender, EventArgs e)
        {
            if (tabControl1.TabPages.Count > 1)
            {
                tabControl1.TabPages.RemoveAt(tabControl1.SelectedIndex);
            }
            else Application.Exit();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            ((ChromiumWebBrowser)tpage.Controls[0]).Load(tsUrl.Text);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question