Unable to deploy CefSharp - CefSharp.Core.Runtime.dll

9k Views Asked by At

I created a new console project and used NuGet to add CefSharp.Common and CefSharp.OffScreen.

I added the following code:

static void Main(string[] args)
{
    try
    {
        ChromiumWebBrowser Chromium = new ChromiumWebBrowser("www.google.com");
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
        Console.WriteLine(ex.Message);
    }
    Console.WriteLine("Test Complete Press Enter to Close Window");
    Console.ReadLine();
}

I then published the project and attempted run it and I received this error: System.IO.FileLoadException: A procedure imported by 'CefSharp.Core.Runtime.dll' could not be loaded.

The following files are in the published folder

  • CefSharp_Test.exe
  • CefSharp_Test.exe.config.deploy
  • CefSharp_Test.exe.deploy
  • CefSharp_Test.exe.manifest
  • CefSharp.Core.dll.deploy
  • CefSharp.Core.Runtime.dll.deploy
  • CefSharp.dll.deploy
  • CefSharp.Offscreen.dll.deploy

I saw that CefSharp recently pushed a change that created the CefSharp.Core.Runtime.dll - https://github.com/cefsharp/CefSharp/issues/3319 and I assume the issue is in some way related to CefSharp determining if the x86 or x64 Runtime.dll should be used but I have been unable to find a way to resolve the issue.

The project does run without issues from Visual Studio.

Edit - From the CefSharp readme it appears that libcef.dll, icudtl.dat, CefSharp.BrowserSubprocess.exe, and CefSharp.BrowserSubprocess.Core.dll are required dependencies. I have added those files to the project, set to copy always, and re-published. The error now reads System.IO.FileNotFoundException: Could not load file or assembly 'CefSharp.Core.Runtime.dll' or one of its dependencies. The specified module could not be found.

Edit - It appears that this is a known issue and will be fixed in a future release of CefSharp. https://github.com/cefsharp/CeSharp/pull/3391

Edit - I attempted to run it using the CefSharp v88.2.40-pre and received the same error.

Edit - CefSharp v88.2.40 has been released. I have attempted to run with that and received the same error.

1

There are 1 best solutions below

2
On

I encountered the same error while doing cefsharp updates today.I deleted cef.redist.x64, cef.redist.x86, CefSharp.Common and CefSharp.WinForms plugins.Then I reinstalled the CefSharp.WinForms plugin from the nuget package manager window.

Gave the same error again.Then I looked at the plugins versions.There were differences between cef.redist.x64, cef.redist.x86 versions and CefSharp.Common, CefSharp.WinForms versions.Because NuGet Package Manager, installed the stable version of the CefSharp.Common and CefSharp.WinForms plugins.

I deleted the plugins again and again.I checked the package sources.I even tried alternatives.Finally, I tried to install the plugins via the package manager console.I installed the following plugins respectively.

Install-Package cef.redist.x86
Install-Package cef.redist.x64
Install-Package CefSharp.Common
Install-Package CefSharp.WinForms

cef.redist.x86 and cef.redist.x64 extensions were installed without any problems.When it came to installing the CefSharp.Common extension, I got an error again.Because, console was trying to install the stable version.

I selected the latest version of CefSharp.Common and CefSharp.WinForms plugins from the nuget package manager window and installed them.And finally I was able to run my project with no errors.

Note: I did this for winform.If there is a difference between versions like mine, you should try it. :)