コード例 #1
0
        static public void Main(string[] args)
        {
            //TODO:Change the project type to "Windows Application" to hide the console
            //If you start the app via Visual Studio , the VS Command Prompt will always show
            CefWin.PrintDebugInformation = true;            //show debug information in console

            CefWin.ApplicationTitle = "MyBlazorApp";        //as the Default Title

            CefWin.ShowSplashScreen("wwwroot/splash.jpg");  //or show System.Drawing.Image from embedded resource

            if (CefWin.ActivateExistingApp())               // Optional, only allow one instance running
            {
                Console.WriteLine("Anoter instance is running , So this instance quit.");
                return;
            }

            //CefWin.SettingAutoSetUserDataStoragePath = false;
            //CefWin.SettingAutoSetCacheStoragePath = false;

            CefWin.SetEnableHighDPISupport();

            CefWin.SearchLibCefSubPathList.Add("chromium");                     // search ./chromium/ for libcef.dll
            CefInitState initState = CefWin.SearchAndInitialize();

            if (initState != CefInitState.Initialized)
            {
                if (initState == CefInitState.Failed)
                {
                    System.Windows.MessageBox.Show("Failed to start application\r\nCheck the github page about how to deploy the libcef.dll", "Error"
                                                   , System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                }
                return;
            }

            using IHost host = CreateHostBuilder(args).Build();
            try
            {
                host.Start();
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
                System.Windows.MessageBox.Show("Failed to start service. Please try again. \r\n" + x.Message, "Error"
                                               , System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                CefWin.CefShutdown();
                return;
            }

            CefWin.ApplicationHost = host;
            CefWin.ApplicationTask = host.WaitForShutdownAsync(CefWin.ApplicationCTS.Token);

            ShowMainForm();

            CefWin.RunApplication();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: BlazorPlus/CefLite
        static public void Main(string[] args)
        {
            CefWin.PrintDebugInformation = true;

            CefWin.ApplicationTitle = "TestCoreApp";             //as the Default Title

            CefWin.SearchLibCefSubPathList.Add("chromium");      // search ./chromium/ for libcef.dll
            CefWin.SearchLibCefSubPathList.Add(@"bin\Debug\netcoreapp3.1\chromium");
            CefInitState initState = CefWin.SearchAndInitialize();

            if (initState != CefInitState.Initialized)
            {
                if (initState == CefInitState.Failed)
                {
                    System.Windows.Forms.MessageBox.Show("Failed to start application\r\nCheck the github page about how to deploy the libcef.dll", "Error"
                                                         , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                return;
            }

            using IHost host = CreateHostBuilder(args).Build();
            try
            {
                host.Start();
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
                System.Windows.Forms.MessageBox.Show("Failed to start service. Please try again. \r\n" + x.Message, "Error"
                                                     , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                CefWin.CefShutdown();
                return;
            }

            CefWin.ApplicationHost = host;
            CefWin.ApplicationTask = host.WaitForShutdownAsync(CefWin.ApplicationCTS.Token);

            ShowMainForm();

            CefWin.RunApplication();
        }