4

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.

jonyfries
  • 772
  • 6
  • 20
  • Per the error message, it looks like the CefSharp.Core.Runtime.dll itself might have a dependency that is not added to your project. Does it have other NuGet package dependencies? – Cornelius J. van Dyk Feb 11 '21 at 20:38
  • The NuGet package installs `cef.redist.x64` and `cef.redist.x86` - my understanding is that those are the `CefSharp.Core.Runtime.dll` depending on if x86 or x64 is the target platform. To my knowledge there aren't any other dependencies but I will look into it more. – jonyfries Feb 11 '21 at 20:42

1 Answers1

4

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. :)

Check78
  • 73
  • 7
  • 1
    I'm confused on what you did that got it working. How did you install CefSharp.Common after installing the latest versions of cef.redist.x86 and cef.redist.x64 (v88.2.4)? – jonyfries Feb 16 '21 at 17:20
  • 1
    @jonyfries I installed the CefSharp.Common from the NuGet Package Manager window.Package manager console installs the stable version.Therefore, it is necessary to select the latest version from the list and install it. – Check78 Feb 19 '21 at 08:54