Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Getting Started CefGlue Gtk (Linux)

softoille@gmail.com edited this page Nov 29, 2019 · 1 revision

Creating .NET CefGlue Gtk Applications (64-bit)

Note: Visual Studio 2017 is preferred. Recent older versions like 2015 should work too but not supported.

Note: Tested on Ubuntu 16.04.4 LTS

On Windows

  1. Create .NET Console Application
  2. Ensure that the build platform target is x64.
  3. From project property, change "Console Application"" to "Windows Application" [Project -> Properties -> Application -> Output type: "Windows Application"].
  4. Add Chromely.CefGlue.Gtk.dll from Nuget or Binaries Folder.
  5. If nuget package is not used in 4, add Chromely.Core.dll from [Binaries Folder]
  6. Add the following code snippet to the Main function in Program.cs.

Notes on Upgrade to CefGlue version 70 and CefSharp version 71 (Chromely v4) - Please see.

class Program
{
   static int Main(string[] args)
   {
      var startUrl = "https://google.com";

      var config = ChromelyConfiguration
                      .Create()
                      .WithHostMode(WindowState.Normal, true)
                      .WithHostTitle("chromely")
                      .WithHostIconFile("chromely.ico")
                      .WithAppArgs(args)
                      .WithHostSize(1000, 600)

                      .WithCommandLineArg("disable-gpu", "1")
                      .WithCommandLineArg("disable-gpu-compositing", "1")
                      .WithCommandLineArg("disable-smooth-scrolling", "1")
                      .WithCommandLineArg("no-sandbox", "1")

                       // Set multi-threaded_message_loop false
                       // only supported on windows
                      .WithCustomSetting(CefSettingKeys.MultiThreadedMessageLoop, false)

                       // .NET Core may not run in debug mode without publishing to exe
                       // To overcome that, a subprocess need to be set.
                       //.WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, path_to_subprocess)
                       .WithStartUrl(startUrl);


      using (var window = ChromelyWindow.Create(config))
      {
         return window.Run(args);
      }
  }
}
- Creates Chromely window of size 1000 x 600 pixels.
- Sets the window title to "chromely"
- Sets start url to "https://google.com"
- Centers the window 

Note that the app is set to run with the following assumptions:

  • No sandbox
  • Disabled gpu processing
  1. Build the project.
  2. Publish the project. Please see how to publish below. For this demo, publishing was done on Windows and files transferred to Ubuntu.

On Linux (Ubuntu) with published self-contained .NET Core

  1. Ensure all folders and files have the right permissions.

  2. Check for missing libcef.so dependencies with:

    • >> sudo ldd libcef.so
    • For this test, found these missing: [Look for ==> not found] - libnss3.so, libnssutil3.so, libsmime3.so - and installed libnss3-dev
    • >> sudo apt-get install libnss3-dev
    • Note: May not be the same issue everywhere.
  3. Get Cef binaries from download page. Base Chromium version 59 or above (64-bit) with version matching Chromely.Unofficial.CefGlue.NetStd installed.

    • Copy all files and folders from /Release to the appropriate bin folder - where the project executable (cefglue_gtk_linux_demo) file is located.
    • Copy all files and folders from /Resources to appropriate bin folder - where the project executable (cefglue_gtk_linux_demo) file is located.

    For more info on cef binaries files/folders layout, please check - CefGlue Application Layout.

  4. To run the executable file

  • >> sudo chmod 755 ./cefglue_gtk_linux_demo
  • >> ./cefglue_gtk_linux_demo
  1. If successful the following will be shown:

On Linux (Ubuntu) with built dlls

This option will not be supported as there are different issues that can arise depending on the Linux distro and what was previously installed and configured.

Some of the issues can be:

  1. Missing dependency libraries. One solution is described above (step 2).
  2. LoadLibrary errors - libcef.so library may not be in the right directory that dotnet.exe can find. One approach is to use directory mapping. Please see sample.
  3. Resource files may also require mapping. Please see more info at CefGlue Linux Support.

Puplishing - Creating self-contained app

The above description will create a SingleProcess chromium application. SingleProcess is not recommended for production for CEF3. To create production level app, the SingleProcess flag must be removed.

  1. Below must be commented out or removed: Note that this only applies to v66 and lower.
   // The single process should only be used for debugging purpose.
   // For production, this should not be needed when the app is published 

   // Alternate approach for multi-process, is to add a subprocess application
   //.WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, path_to_subprocess)
   .WithCustomSetting(CefSettingKeys.SingleProcess, true)
  1. Add platform RuntimeIdentifiers flags in the project file.
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifiers>win10-x64;ubuntu.16.10-x64</RuntimeIdentifiers>
    <Platforms>x64</Platforms>
  </PropertyGroup>
  1. Look for online help to create .NET Core self-contained apps if needed. An example can be found here.
  2. See demo project here.

Not Working Yet

The following functions currently work on Windows but not on Linux yet. They will be revisited. Help/contribution will also be appreciated.

  1. The window resizing is not working yet.
  2. The application icon is not properly set.
Clone this wiki locally