Getting Started CefGlue Winapi (.NET Core) - RupertAvery/Chromely GitHub Wiki
Note: Visual Studio 2017 is preferred. Recent older versions like 2015 should work too but not supported.
- Create .NET Core 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"].
- To ensure that all required dlls are built in the right bin folder, add the following to the project file:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>- Add Chromely.CefGlue.Winapi from Nuget-prelease. (A warning may show, if this happens unload the project and reload.)
- Chromely.CefGlue.Winapi has following dependencies and should be verified
- After adding the dll references, a warning may show, if this happens unload the project and reload.
- 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)
{
string startUrl = "https://www.google.com/";
var config = ChromelyConfiguration
.Create()
.WithHostMode(WindowState.Normal, true)
.WithHostTitle("chromely")
.WithHostIconFile("chromely.ico")
.WithAppArgs(args)
.WithHostSize(1000, 600)
// .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://www.google.com/"
- Centers the window -
Build the project. From version 66 and above, building the project also downloads the required CEF binaries.
-
From Chromely.CefGlue.Winapi version 66 and upward, CEF binaries download is not required anymore. Only valid for nuget packages
-
Note: .NET Core sometimes gives a "An attempt was made to load a program with an incorrect format.". This is a bug due to .NET and .NET Core build processes not picking the appropriate CPU. If this happens a manual CEF binaries download is required.
-
If CEF binaries files/folders download is required, please try either of these two options-
-
-
Run the built dll file with F5 or "dotnet demo.dll"on cmd.
-
If successful the following will be shown:

- 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.
Launching the app using published self-contained exe will also launch the console window. One way to stop this is to use EDITBIN.EXE tool.
Using
editbin.exe /subsystem:windows cefglue_winapi_netcoredemo.exeYou can see more info on this, in the following: