Esempio n. 1
0
        /// <summary>
        /// 初始化设置
        /// </summary>
        private void InitSetting()
        {
            var settings = new CefSettings
            {
                RemoteDebuggingPort = 8088,
                CachePath           = "cache",
                UserAgent           = string.Format("ChromeClient/{0} Mozilla/5.0 (Windows NT 6.1; WOW64)  {1} AppleWebKit/537.36 Safari/537.36",
                                                    Assembly.GetExecutingAssembly().GetName().Version, VersionNumberString),
                IgnoreCertificateErrors    = true,
                PackLoadingDisabled        = false,
                WindowlessRenderingEnabled = false
            };

            //Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
            settings.CefCommandLineArgs.Add("debug-plugin-loading", "1");
            settings.CefCommandLineArgs.Add("allow-outdated-plugins", "1");
            settings.CefCommandLineArgs.Add("always-authorize-plugins", "1");
            settings.CefCommandLineArgs.Add("enable-npapi", "1");
            settings.LogSeverity = LogSeverity.Verbose;
            Cef.AddWebPluginDirectory(@".\Plugins");
            Cef.AddWebPluginPath(@".\Plugins\NPSWF32_18_0_0_95.dll");

            _loggor.Info("Initialize Cef");
            if (!Cef.Initialize(settings))
            {
                _loggor.Error("Cef initialize failed.");
            }

            if (Cef.IsInitialized)
            {
                _loggor.Info("Cef initialize successed." + VersionNumberString);
            }
            else
            {
                Cef.Shutdown();
                MessageBox.Show(MessageResource.CoreErrorTip);
            }
        }