-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started CefGlue Gtk (Linux)
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
- Create .NET Console Application
- Ensure that the build platform target is x64.
- From project property, change "Console Application"" to "Windows Application" [Project -> Properties -> Application -> Output type: "Windows Application"].
- Add Chromely.CefGlue.Gtk.dll from Nuget or Binaries Folder.
- If nuget package is not used in 4, add Chromely.Core.dll from [Binaries Folder]
- 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
- Build the project.
- Publish the project. Please see how to publish below. For this demo, publishing was done on Windows and files transferred to Ubuntu.
-
Ensure all folders and files have the right permissions.
-
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.
-
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.
-
To run the executable file
- >> sudo chmod 755 ./cefglue_gtk_linux_demo
- >> ./cefglue_gtk_linux_demo
- If successful the following will be shown:
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:
- Missing dependency libraries. One solution is described above (step 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.
- Resource files may also require mapping. Please see more info at CefGlue Linux Support.
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.
- 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)
- 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>
- Look for online help to create .NET Core self-contained apps if needed. An example can be found here.
- See demo project here.
The following functions currently work on Windows but not on Linux yet. They will be revisited. Help/contribution will also be appreciated.
- The window resizing is not working yet.
- The application icon is not properly set.
Chromely
Getting Started
The Basics
Digging Deeper
- Sub-Process
- Infrastructure
- Restful Resources
- Register Resource Assemblies
- Custom Local Resource Handling
- Custom Scheme Handling
- Expose .NET class to JavaScript
- Generic Message Routing
- Real-time with Websocket
- External Url Registration
Angular - React - Vue