static void Main() { CfxRuntime.LibCefDirPath = $@"{CefRepo}\Release"; var returnValue = CfxRuntime.ExecuteProcess(); Environment.Exit(returnValue); }
public static void Main() { var assemblyDir = System.IO.Path.GetDirectoryName(new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); Environment.CurrentDirectory = System.IO.Path.Combine(assemblyDir, @"..\..\"); if (CfxRuntime.PlatformArch == CfxPlatformArch.x64) { CfxRuntime.LibCefDirPath = @"cef\Release64"; } else { CfxRuntime.LibCefDirPath = @"cef\Release"; } Chromium.WebBrowser.ChromiumWebBrowser.OnBeforeCfxInitialize += ChromiumWebBrowser_OnBeforeCfxInitialize; ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing; Chromium.WebBrowser.ChromiumWebBrowser.Initialize(); //Walkthrough01.Main(); //return; Application.EnableVisualStyles(); var f = new BrowserForm(); f.Show(); Application.Run(f); CfxRuntime.Shutdown(); }
// Main entry point when called by vvvv public static void Start() { CfxRuntime.LibCefDirPath = Globals.AssemblyDir; var app = new CfxApp(); app.OnBeforeCommandLineProcessing += app_OnBeforeCommandLineProcessing; BrowserProcessHandler = new CfxBrowserProcessHandler(); BrowserProcessHandler.OnBeforeChildProcessLaunch += (sender, args) => { args.CommandLine.AppendSwitchWithValue("vvvv-pid", Process.GetCurrentProcess().Id.ToString()); }; app.GetBrowserProcessHandler += (sender, args) => args.SetReturnValue(BrowserProcessHandler); var settings = new CfxSettings { //PackLoadingDisabled = true, WindowlessRenderingEnabled = true, NoSandbox = true, UserDataPath = Path.Combine(Globals.AssemblyDir, "userdata"), CachePath = Path.Combine(Globals.AssemblyDir, "cache"), BrowserSubprocessPath = Globals.AssemblyLocation, LogSeverity = CfxLogSeverity.Disable, //SingleProcess = false, // DEBUG MultiThreadedMessageLoop = true, // false IgnoreCertificateErrors = true, RemoteDebuggingPort = 8088, }; Started = true; CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain); }
public frmWelcome() : base("embedded://www/index.html") //设定启示页面,scheme是embedded就是我们在Main里注册的当前程序集资源 { InitializeComponent(); //在js中注册一个方法来打开About窗口 GlobalObject.AddFunction("showAboutForm").Execute += (sender, args) => { ShowAboutNanUI(); //ShowAboutWindow(); }; GlobalObject.AddFunction("showDevTools").Execute += (sender, args) => { ShowDevTools(); }; //网页加载完成时触发事件 LoadHandler.OnLoadEnd += (sender, args) => { //判断下触发的事件是不是主框架的 if (args.Frame.IsMain) { //执行JS,将当前的CEF运行版本等信息通过JS加载到网页上 var js = $"$client.setRuntimeInfo({{ api: ['{CfxRuntime.ApiHash(0)}', '{CfxRuntime.ApiHash(1)}'], cef:'{CfxRuntime.GetCefVersion()}', chrome:'{CfxRuntime.GetChromeVersion()}',os:'{CfxRuntime.PlatformOS}', arch:'{CfxRuntime.PlatformArch}'}});"; ExecuteJavascript(js); } }; }
static void Main() { CfxRuntime.LibCefDirPath = @"cef\Release"; int retval = CfxRuntime.ExecuteProcess(); Environment.Exit(retval); }
private void Initialize() { CfxRuntime.LibCefDirPath = @"cef\Release"; int retval = CfxRuntime.ExecuteProcess(); var app = new CfxApp(); var processHandler = new CfxBrowserProcessHandler(); app.GetBrowserProcessHandler += (sender, e) => e.SetReturnValue(processHandler); var path = Path.Combine(GetType().Assembly.GetPath(), "ChromiumFXRenderProcess.exe"); var settings = new CfxSettings { SingleProcess = false, BrowserSubprocessPath = path, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = true, NoSandbox = true, LocalesDirPath = System.IO.Path.GetFullPath(@"cef\Resources\locales"), ResourcesDirPath = System.IO.Path.GetFullPath(@"cef\Resources") }; if (!CfxRuntime.Initialize(settings, app, RenderProcessStartup)) { throw new Exception("Failed to initialize CEF library."); } Thread.Sleep(200); }
private ChromiumFxSession(Action <CfxSettings> settingsBuilder, Action <CfxBrowserSettings> browserSettingsUpdater, Action <CfxOnBeforeCommandLineProcessingEventArgs> commandLineHandler, IWebSessionLogger webSessionLogger) { _CurrentDirectory = this.GetType().Assembly.GetPath(); _SettingsBuilder = settingsBuilder; _CommandLineHandler = commandLineHandler; CfxRuntime.LibCefDirPath = GetPath($@"{CefRepo}\Release"); ChromiumWebBrowser.OnBeforeCfxInitialize += ChromiumWebBrowser_OnBeforeCfxInitialize; ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing; int value = CfxRuntime.ExecuteProcess(); if (value >= 0) { Environment.Exit(value); } CfxRuntime.EnableHighDpiSupport(); ChromiumWebBrowser.Initialize(); browserSettingsUpdater?.Invoke(NeutroniumSettings.NeutroniumBrowserSettings); _NeutroniumSchemeHandlerFactory = new NeutroniumSchemeHandlerFactory(webSessionLogger); //need this to make request interception work CfxRuntime.RegisterSchemeHandlerFactory("https", "application", _NeutroniumSchemeHandlerFactory); }
/// <summary> /// 在浏览器初始化之前执行事件 /// </summary> /// <param name="sender">传递对象</param> /// <param name="e">浏览器初始化之前执行事件参数</param> private void ChromiumFx_OnBeforeCfxInitialize(object sender, OnBeforeCfxInitializeEventArgs e) { CfxRuntime.EnableHighDpiSupport(); e.Settings.SingleProcess = true; //e.Settings.BrowserSubprocessPath = Path.GetFullPath("ChromiumFXRenderProcess.exe"); //缓存数据存放位置 e.Settings.CachePath = Path.GetFullPath($@"{_basePath}\LocalCache"); //启用无窗口渲染 e.Settings.WindowlessRenderingEnabled = true; //无沙箱 e.Settings.NoSandbox = true; //集成消息循环(Message Loop Integration) //仅 Windows 操作系统有效 e.Settings.MultiThreadedMessageLoop = true; //禁用日志 e.Settings.LogSeverity = CfxLogSeverity.Disable; //指定中文为当前CEF环境的默认语言 e.Settings.AcceptLanguageList = "zh-CN"; e.Settings.Locale = "zh-CN"; //资源文件及语言环境目录 e.Settings.LocalesDirPath = Path.GetFullPath($@"{_basePath}\Resources\locales"); e.Settings.ResourcesDirPath = Path.GetFullPath($@"{_basePath}\Resources"); }
public static bool PrepareRuntime() { if (!System.IO.Directory.Exists(CommonRuntimeDir)) { System.IO.Directory.CreateDirectory(CommonRuntimeDir); } if (IsLocalRuntimeExisits() == false) { if (IsRuntimeExists() == false) { var downloadForm = new RuntimeDownloadForm(CommonRuntimeDir, CURRENT_CEF_VERSION, FrameworkDownloadUrl, PlatformArch, EnableFlashSupport); if (downloadForm.ShowDialog() != DialogResult.OK || !IsRuntimeExists()) { return(false); } } } CfxRuntime.LibCefDirPath = FrameworkDir; Application.ApplicationExit += (sender, args) => { foreach (var handle in SchemeHandlerGCHandles) { handle.Free(); } CfxRuntime.Shutdown(); }; return(true); }
// Main entry point when called by vvvv void IStartable.Start() { var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); CfxRuntime.LibCefDirPath = assemblyDir; CfxApp app = new CfxApp(); app.OnBeforeCommandLineProcessing += app_OnBeforeCommandLineProcessing; var settings = new CfxSettings { //PackLoadingDisabled = true, WindowlessRenderingEnabled = true, NoSandbox = true, UserDataPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "userdata"), CachePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cache"), BrowserSubprocessPath = Assembly.GetExecutingAssembly().Location, LogSeverity = CfxLogSeverity.Disable, SingleProcess = false, // DEBUG MultiThreadedMessageLoop = true, // false IgnoreCertificateErrors = true, }; CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain); }
private static void Application_ApplicationExit(object sender, EventArgs e) { //to kill subprocess in windows . because on windows when application exited,will left a subprocess can not auto shutdown. if (CfxRuntime.PlatformOS == CfxPlatformOS.Windows) { var current = Process.GetCurrentProcess(); var processName = current.ProcessName; var sublist = Process.GetProcessesByName(processName); var realSublist = sublist.Where(p => p.Id != current.Id).ToList(); foreach (var process in realSublist) { try { process.Kill(); } catch (Exception ex) { } } } else { CfxRuntime.QuitMessageLoop(); } CfxRuntime.Shutdown(); }
private static void OnApplicationExit(object sender, EventArgs e) { foreach (var handle in SchemeHandlerGCHandles) { handle.Free(); } CfxRuntime.Shutdown(); }
public static void RegisterCustomScheme(string schemeName, string doamin, CfxSchemeHandlerFactory factory) { if (string.IsNullOrEmpty(schemeName)) { throw new ArgumentNullException("schemeName", "必须为scheme指定名称。"); } var result = CfxRuntime.RegisterSchemeHandlerFactory(schemeName, doamin, factory); }
static void Main() { string nowDir = AppDomain.CurrentDomain.BaseDirectory; if (!System.IO.File.Exists(System.IO.Path.Combine(nowDir, "libcfx.dll"))) { if (MessageBox.Show("并没有在软件目录下找到基本运行库\n您应该在获得这款软件的时候同时获得关于本软件依赖库的信息\n如果没有,您可以到本软件的Github Wiki获得帮助\n是否现在前往?", "未能找到依赖库", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start("https://github.com/huix-oldcat/ArkDesktop/wiki"); } return; } CfxRuntime.LibCefDirPath = System.IO.Path.Combine(nowDir, "cef"); CfxRuntime.LibCfxDirPath = nowDir; int exitCode = CfxRuntime.ExecuteProcess(null); if (exitCode >= 0) { Environment.Exit(exitCode); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (var settings = new CfxSettings()) { settings.MultiThreadedMessageLoop = true; settings.WindowlessRenderingEnabled = true; settings.NoSandbox = true; settings.ResourcesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources"); settings.LocalesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources", "locales"); var app = new CfxApp(); app.OnBeforeCommandLineProcessing += (s, e) => { // optimizations following recommendations from issue #84 e.CommandLine.AppendSwitch("disable-gpu"); e.CommandLine.AppendSwitch("disable-gpu-compositing"); e.CommandLine.AppendSwitch("disable-gpu-vsync"); }; if (!CfxRuntime.Initialize(settings, app)) { Environment.Exit(-1); } } Manager.layeredWindow = new LayeredWindow(); Manager.control = new ArkDesktopBrowserControl(); Manager.Init(); Application.Run(Manager.layeredWindow); // CfxRuntime.QuitMessageLoop(); CfxRuntime.Shutdown(); }
static void Main() { ChromiumWebBrowser.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MyDemo()); CfxRuntime.Shutdown(); }
private void Init() { if (_Runing) { return; } _Runing = true; _WpfThread.Dispatcher.Invoke(Initialize); _WpfThread.OnThreadEnded += (o, e) => CfxRuntime.Shutdown(); }
static void Main() { CfxRuntime.LibCefDirPath = @"cef\Release"; var app = new CfxApp(); var handler = new CfxRenderProcessHandler(); app.GetRenderProcessHandler += (sender, args) => args.SetReturnValue(handler); int retval = CfxRuntime.ExecuteProcess(app); Environment.Exit(retval); }
public static void RegisterScheme(string schemeName, string domain, CfxSchemeHandlerFactory factory) { var gchandle = GCHandle.Alloc(factory); SchemeHandlerGCHandles.Add(gchandle); if (string.IsNullOrEmpty(schemeName)) { throw new ArgumentNullException("schemeName", "must set up the schema name."); } CfxRuntime.RegisterSchemeHandlerFactory(schemeName, domain, factory); }
private static string GetMineType(StreamResourceInfo streamResourceInfo, Uri uri) { var type = streamResourceInfo.ContentType; if (!string.IsNullOrEmpty(type)) { return(type); } var extension = Path.GetExtension(uri.AbsoluteUri).Replace(".", ""); return(CfxRuntime.GetMimeType(extension)); }
private ChromiumFxSession(Action <CfxSettings> settingsBuilder, Action <CfxOnBeforeCommandLineProcessingEventArgs> commadLineHandler, IWebSessionLogger webSessionLogger) { _CurrentDirectory = this.GetType().Assembly.GetPath(); _SettingsBuilder = settingsBuilder; _CommandLineHandler = commadLineHandler; CfxRuntime.LibCefDirPath = GetPath(@"cef\Release"); ChromiumWebBrowser.OnBeforeCfxInitialize += ChromiumWebBrowser_OnBeforeCfxInitialize; ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing; ChromiumWebBrowser.Initialize(); //need this to make request interception work CfxRuntime.RegisterSchemeHandlerFactory("pack", null, new PackUriSchemeHandlerFactory(webSessionLogger)); }
public static void Main() { ChromiumWebBrowser.OnBeforeCfxInitialize += ChromiumWebBrowser_OnBeforeCfxInitialize; ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing; ChromiumWebBrowser.Initialize(); Application.EnableVisualStyles(); var winform = new BrowserForm(); winform.Show(); Application.Run(winform); CfxRuntime.Shutdown(); }
private void ChromiumWebBrowser_OnBeforeCfxInitialize(OnBeforeCfxInitializeEventArgs e) { CfxRuntime.EnableHighDpiSupport(); var settings = e.Settings; _SettingsBuilder?.Invoke(settings); settings.LocalesDirPath = GetPath($@"{CefRepo}\Resources\locales"); settings.Locale = Thread.CurrentThread.CurrentCulture.ToString(); settings.ResourcesDirPath = GetPath($@"{CefRepo}\Resources"); settings.BrowserSubprocessPath = GetPath("ChromiumFXRenderProcess.exe"); settings.MultiThreadedMessageLoop = true; settings.NoSandbox = true; }
public MainForm() : base("embedded://www/index3.html") { InitializeComponent(); //在js中注册一个方法来打开About窗口 GlobalObject.AddFunction("showAboutForm").Execute += (sender, args) => { ShowAboutNanUI(); //ShowAboutWindow(); }; GlobalObject.AddFunction("showDevTools").Execute += (sender, args) => { ShowDevTools(); }; LifeSpanHandler.OnBeforePopup += (sender, args) => { }; LifeSpanHandler.OnAfterCreated += (sender, args) => { }; //网页加载完成时触发事件 LoadHandler.OnLoadEnd += (sender, args) => { //判断下触发的事件是不是主框架的 if (args.Frame.IsMain) { //执行JS,将当前的CEF运行版本等信息通过JS加载到网页上 //var js = string.Format("$client.setRuntimeInfo({{ api: ['{CfxRuntime.ApiHash(0)}', '{CfxRuntime.ApiHash(1)}'], cef:'{CfxRuntime.GetCefVersion()}', chrome:'{CfxRuntime.GetChromeVersion()}',os:'{CfxRuntime.PlatformOS}', arch:'{CfxRuntime.PlatformArch}'}});"); var js = string.Format("alert('{0}')", CfxRuntime.ApiHash(1)); object a = CfxRuntime.GetCefVersion(); //ExecuteJavascript(js); this.UpdateUI(() => { //显示字窗体的过程,不解释 SubForm su = new SubForm(); su.Show(); }); } }; }
static void Main() { string nowDir = Environment.CurrentDirectory; CfxRuntime.LibCefDirPath = System.IO.Path.Combine(nowDir, "cef"); CfxRuntime.LibCfxDirPath = nowDir; int exitCode = CfxRuntime.ExecuteProcess(null); if (exitCode >= 0) { Environment.Exit(exitCode); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (var settings = new CfxSettings()) { settings.MultiThreadedMessageLoop = true; settings.WindowlessRenderingEnabled = true; settings.NoSandbox = true; settings.ResourcesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources"); settings.LocalesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources", "locales"); var app = new CfxApp(); app.OnBeforeCommandLineProcessing += (s, e) => { // optimizations following recommendations from issue #84 e.CommandLine.AppendSwitch("disable-gpu"); e.CommandLine.AppendSwitch("disable-gpu-compositing"); e.CommandLine.AppendSwitch("disable-gpu-vsync"); }; if (!CfxRuntime.Initialize(settings, app)) { Environment.Exit(-1); } } Manager.layeredWindow = new LayeredWindow(); Manager.control = new ArkDesktopBrowserControl(); Manager.Init(); Application.Run(Manager.layeredWindow); // CfxRuntime.QuitMessageLoop(); CfxRuntime.Shutdown(); }
public static void Main() { //CfxRuntime.LoadLibraries(@"C:\path\to\cef\directory"); //ChromiumWebBrowser.OnBeforeCfxInitialize += ChromiumWebBrowser_OnBeforeCfxInitialize; //ChromiumWebBrowser.Initialize(); Form f = new Form(); f.Size = new Size(800, 600); ChromiumWebBrowser wb = new ChromiumWebBrowser(); wb.Dock = DockStyle.Fill; wb.Parent = f; wb.GlobalObject.AddFunction("HelloApp").Execute += HelloApp_Execute; wb.GlobalObject.AddFunction("DoSomething").Execute += DoSomething_Execute; //wb.ExecuteJavascript("var x = HelloApp();"); var html = " <button onclick='var x = HelloApp(12345); document.getElementById(\"demo\").innerHTML =x;'>"; html += "Trigger HelloApp(12345) callback function.</button><br><br><img src='http://localresource/image'>"; html += "<br><p>Callback returned: <span id='demo'></span></p>"; html += "<br><br><button onclick='DoSomething();'>Do something</button>"; var bm = new System.Drawing.Bitmap(100, 100); using (var g = System.Drawing.Graphics.FromImage(bm)) { g.DrawLine(System.Drawing.Pens.Black, 0, 0, 100, 100); } wb.SetWebResource("http://localresource/text.html", new Chromium.WebBrowser.WebResource(html)); wb.SetWebResource("http://localresource/image", new Chromium.WebBrowser.WebResource(bm)); f.Show(); wb.LoadUrl("http://localresource/text.html"); Application.Run(f); CfxRuntime.Shutdown(); }
public void MainThread(object coreInst) { core = (Core)coreInst; additionalPath = Path.Combine(core.RootPath, "./Resources/ArkDesktop.Cfx/"); if (CheckLibs() == false) { return; } int exitCode = CfxRuntime.ExecuteProcess(null); using (var settings = new CfxSettings()) { settings.MultiThreadedMessageLoop = true; settings.WindowlessRenderingEnabled = true; settings.NoSandbox = true; settings.ResourcesDirPath = Path.Combine(additionalPath, "cef", "Resources"); settings.LocalesDirPath = Path.Combine(additionalPath, "cef", "Resources", "locales"); settings.BrowserSubprocessPath = Path.Combine(additionalPath, "ArkDesktopCfxSubProcess.exe"); settings.LogFile = "C:/Users/z1223/Desktop/log.txt"; var app = new CfxApp(); app.OnBeforeCommandLineProcessing += (s, e) => { // optimizations following recommendations from issue #84 e.CommandLine.AppendSwitch("disable-gpu"); e.CommandLine.AppendSwitch("disable-gpu-compositing"); e.CommandLine.AppendSwitch("disable-gpu-vsync"); }; app.OnRegisterCustomSchemes += App_OnRegisterCustomSchemes; if (!CfxRuntime.Initialize(settings, app)) { return; } CfxRuntime.RegisterSchemeHandlerFactory("akd", "test", new ResourceManager.SchemeHandlerFactory(Path.Combine(core.RootPath, "Resources\\"))); } CreateThreads(); manager = new ArkDesktopBrowserControl(window); while (!disposed) { CfxRuntime.DoMessageLoopWork(); } }
internal static void Initialize() { if (initialized) { throw new HtmlUIException("ChromiumWebBrowser library already initialized."); } int retval = CfxRuntime.ExecuteProcess(); if (retval >= 0) { Environment.Exit(retval); } app = new CfxApp(); processHandler = new CfxBrowserProcessHandler(); app.GetBrowserProcessHandler += (s, e) => e.SetReturnValue(processHandler); app.OnBeforeCommandLineProcessing += (s, e) => HtmlUILauncher.RaiseOnBeforeCommandLineProcessing(e); app.OnRegisterCustomSchemes += (s, e) => HtmlUILauncher.RaiseOnRegisterCustomSchemes(e); var settings = new CfxSettings(); settings.MultiThreadedMessageLoop = true; settings.NoSandbox = true; HtmlUILauncher.RaiseOnBeforeCfxInitialize(settings, processHandler); if (!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain)) { throw new HtmlUIException("Failed to initialize CEF library."); } initialized = true; }
public static bool PrepareRuntime() { if (IsLocalRuntimeExisits() == false) { //if (IsRuntimeExists() == false) //{ // var downloadForm = new RuntimeDownloadForm(CommonRuntimeDir, CURRENT_CEF_VERSION, FrameworkDownloadUrl, PlatformArch, EnableFlashSupport); // if (downloadForm.ShowDialog() != DialogResult.OK || !IsRuntimeExists()) // { // return false; // } //} MessageBox.Show($"CEF Runtime is not found.\r\nCEF Runtime should be in\r\n\"{System.IO.Path.Combine(Application.StartupPath, "fx\\")}\"", "CEF Runtime initialize faild", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } CfxRuntime.LibCefDirPath = FrameworkDir; Application.ApplicationExit += (sender, args) => { foreach (var handle in SchemeHandlerGCHandles) { handle.Free(); } CfxRuntime.Shutdown(); }; return(true); }
/// <summary> /// 初始化 /// </summary> internal static void Initialize() { if (initialized) { throw new WebEngineException("对不起!初始化工作已经完成,请勿重复执行初始化工作。"); } int retval = CfxRuntime.ExecuteProcess(); if (retval >= 0) { Environment.Exit(retval); } app = new CfxApp(); processHandler = new CfxBrowserProcessHandler(); app.GetBrowserProcessHandler += (s, e) => e.SetReturnValue(processHandler); app.OnBeforeCommandLineProcessing += (s, e) => Bootstrapper.RaiseOnBeforeCommandLineProcessing(e); app.OnRegisterCustomSchemes += (s, e) => Bootstrapper.RaiseOnRegisterCustomSchemes(e); var settings = new CfxSettings(); settings.MultiThreadedMessageLoop = true; settings.NoSandbox = true; Bootstrapper.RaiseOnBeforeCfxInitialize(settings, processHandler); //if (!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain)) if (!CfxRuntime.Initialize(settings, app)) { throw new WebEngineException("对不起!无法初始化 CEF 运行库。"); } initialized = true; }
static void Main(string[] args) { Environment.CurrentDirectory = FileHelper.AppPath; CfxRuntime.LibCefDirPath = Path.GetFullPath($@"{_basePath}\{CfxRuntime.PlatformArch.ToString()}"); CfxRuntime.LibCfxDirPath = Path.GetFullPath($"{_basePath}"); if (!Directory.Exists(CfxRuntime.LibCefDirPath)) { throw new DirectoryNotFoundException("Sorry! The CEF configuration directory was not found. Please confirm and try again."); } ChromiumWebBrowser.OnBeforeCfxInitialize += new OnBeforeCfxInitializeEventHandler(ChromiumWebBrowser_OnBeforeCfxInitialize); ChromiumWebBrowser.OnBeforeCommandLineProcessing += new OnBeforeCommandLineProcessingEventHandler(ChromiumWebBrowser_OnBeforeCommandLineProcessing); ChromiumWebBrowser.Initialize(); Application.EnableVisualStyles(); var f = new BrowserForm(); f.Show(); Application.Run(f); CfxRuntime.Shutdown(); }