找不到Cefsharp CefSettings和RegisterScheme

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

我已经通过nuget安装了cefsharp,复制了所需的dll,在表单中添加了一个Web视图并运行了应用程序,它运行良好。但是,当我尝试使用Cef初始化Cef来启动自定义请求处理和那些东西时,Visual Studio找不到CefSettingsCef类。我正在使用最新的CefSharp 1.25.3 for winforms。

码:

var settings = new CefSettings {RemoteDebuggingPort = 8088};
settings.RegisterScheme(new CefCustomScheme
{
    SchemeName = CefSharpSchemeHandlerFactory.SCHEME_NAME,
    SchemeHandlerFactory = new CefSharpSchemeHandlerFactory()
});

if (!Cef.Initialize(settings)) {
    if (Environment.GetCommandLineArgs().Contains("--type=renderer")) {
        Environment.Exit(0);
    }
    else {
        return;
    }
}

Cef.RegisterJsObject("bound", new BoundObject());
c# chromium-embedded cefsharp
1个回答
1
投票

如果调用Cef.Initialize会抛出异常,说明缺少引用,则可能必须确保所有依赖项,尤其是非托管依赖项都位于工作目录中。可以在CefSharp FAQ中找到所需资源的列表:https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#Runtime_dependencies

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