Unable to locate required Cef/CefSharp dependencies
Asked Answered
P

3

5

I have a C# console application that is deployed on client machines. While deploying in client machine I get System.TypeInitializationException.

In debug.log, I get the following errors:

Unable to locate required Cef/CefSharp dependencies:
Missing:CefSharp.BrowserSubprocess.exe
Missing:CefSharp.BrowserSubprocess.Core.dll
Missing:CefSharp.Core.dll
Missing:CefSharp.dll
Missing:icudtl.dat
Missing:libcef.dll
Executing Assembly Path:C:\myapp

The problem is that all files are present in the C:\myapp directory (as specified here). Therefore, I'm not sure why these files aren't being loaded up. Also msvcp120.dll, msvcr120.dll, vccorlib120.dll included in c:\myapp directory

Penn answered 25/12, 2016 at 15:31 Comment(2)
You can disable dependency checking, it's a parameter of Cef.InitializeClinical
@Clinical The issue disappeared after reverting my code to simulate it again, so it was probably environment related.Musk
S
9

As many people, I followed the steps in the official Quick Start article to setup the "Any CPU" configuration and I had the same problem with missing dependencies when performDependencyCheck was on.

This is because the article is actually incomplete!

For the "Any CPU" configuration to work, you need to follow all the steps in Feature Request - Add AnyCPU Support #1714 (especially the last one!):

example below:

[STAThread]
public static void Main()
{
  var settings = new CefSettings();
  settings.BrowserSubprocessPath = @"x86\CefSharp.BrowserSubprocess.exe";

  Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);

  var browser = new BrowserForm();
  Application.Run(browser);
}

Note: when using this code, I would still advise you to use performDependencyCheck: true since it will now report only genuine errors.

Skald answered 28/11, 2017 at 9:38 Comment(3)
I would left performDependencyCheck in truePhycomycete
Yes you're right, performDependencyCheck should be left "true". I just quoted the example from the ticket. I'll add a not to my answer though. ThanksSkald
settings.browserSubprocessPath can no longer be relative. github.com/cefsharp/CefSharp/issues/3112 Instead, use this: settings.BrowserSubprocessPath = System.IO.Path.GetFullPath("x86\\CefSharp.BrowserSubprocess.exe");Presser
C
3

I meet the same problem today.

My CEFSharp program works fine when only opening my program, but it's failed when open the associating files.

When I double click to open an associating format file (eg: JPG format file), the application startup fails because of "Unable to locate required Cef/CefSharp dependencies" error.

I tried to set "performDependencyCheck: false", it works when right clicking to choose the My program to open the file. But when double click the jpeg file, the error still stay.

Then I tried to set the current directory to execute file path, it looks works, I think this issue rootcause sometimes is related with the current working folder not right.

    private static void Main(string[] args)
    {
        try
        {
            string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            if (exeDir != null)
            {
                Directory.SetCurrentDirectory(exeDir);
            }

            if (!Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: browserProcessHandler))
            {
                throw new Exception("Unable to Initialize Cef");
            }
Carrasquillo answered 12/12, 2018 at 10:54 Comment(1)
This worked for me. I was launching my CefSharp app from a browser using a custom URI Scheme, and the current directory was being set to the browser's directory (e.g., `C:\Program Files (x86)\Google\Chrome\Application[Version]`). Setting the current directory to the CefSharp application's location resolved the dependency check issue.Tinishatinker
B
1

I had the same issue. first I saw that the Cef.Initialize() function just don't work, so I enabled the performDependencyCheck option like this:

Cef.Initialize(BrowserSettings, performDependencyCheck: true, browserProcessHandler: null);

(According to this example https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.OffScreen/Program.cs)

and I saw I am missing some files.

Afterwards, the error kept showing up, even though I don't miss anything. so i disabled the performDependencyCheck option and it worked.(like this:

Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);

Hope it will help you.

Bondage answered 6/2, 2017 at 7:42 Comment(2)
The 55.0.0 packages have gitlink support so you can easily debug the source on your dev machine. github.com/GitTools/GitLink#gitlinkClinical
I got tempted to disable the performDependencyCheck too, but then I realised that I could not execute JavaScript in the main frame. So I would discourage from doing so. See my answer instead.Skald

© 2022 - 2024 — McMap. All rights reserved.