方法'Initialize'没有重载需要0个参数

问题描述 投票:0回答:2

我是C#的新手,我正在尝试按照本教程实施CefSharp:https://www.codeproject.com/Articles/990346/Using-HTML-as-UI-Elements-in-a-WinForms-Applicatio#_articleTop

但是,当我尝试使用他在第一个片段中提供的代码时,我得到了;

错误CS1501方法'Initialize'没有重载需要0个参数

我查看了这个错误的其他实例,但它涉及的错误数量的争论,我不相信应该有一个争论初始化。

任何帮助将不胜感激(很可能是一个非常简单的错误),谢谢

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 multidiscordmanager {
    public partial class Form1 : Form
    {
        private void Form1_Load(object sender, EventArgs e)
        {
            Cef.Initialize();
            ChromiumWebBrowser myBrowser = new ChromiumWebBrowser("http://www.maps.google.com");
            this.Controls.Add(myBrowser);
        }

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

    }
}
c# cefsharp
2个回答
0
投票

您引用的教程已过时且过时。

在版本67.0.0中,删除了Cef.Initialize(),可以安全地删除该行代码。如果要提供自定义设置,则只需要调用Cef.Initlalize(设置)。要使用默认值初始化,ChromiumWebBrowser的第一个实例将为您执行此操作。

有关背景信息,请参阅https://github.com/cefsharp/CefSharp/wiki/General-Usage#initialize-and-shutdown


-1
投票

在WinForms中工作时,我们经常会看到像InitializeComponent这样的东西,实际上它们没有参数。

您正在调用的是Cef.Initialize,其中according to the CEFSharp documentation采用CefSettings settings的参数

编辑:我显然是盲目的,并且文档中有一个无参数的超载,但是你的班级显然无法使用它。

如果您没有看到不带参数的重载,那么其他东西就像库版本或框架一样不匹配。

© www.soinside.com 2019 - 2024. All rights reserved.