diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h
index 26eec278e..d186c2d2c 100644
--- a/CefSharp.Core/Cef.h
+++ b/CefSharp.Core/Cef.h
@@ -160,9 +160,14 @@ namespace CefSharp
// NOTE: Can only initialize Cef once, so subsiquent calls are ignored.
if (!IsInitialized)
{
+ if (cefSettings->BrowserSubprocessPath == nullptr)
+ {
+ throw gcnew Exception("CefSettings BrowserSubprocessPath cannot be null.");
+ }
+
if(performDependencyCheck)
{
- DependencyChecker::AssertAllDependenciesPresent(cefSettings->Locale, cefSettings->LocalesDirPath, cefSettings->ResourcesDirPath, cefSettings->PackLoadingDisabled);
+ DependencyChecker::AssertAllDependenciesPresent(cefSettings->Locale, cefSettings->LocalesDirPath, cefSettings->ResourcesDirPath, cefSettings->PackLoadingDisabled, cefSettings->BrowserSubprocessPath);
}
CefMainArgs main_args;
diff --git a/CefSharp/DependencyChecker.cs b/CefSharp/DependencyChecker.cs
index 0fb0f84b2..6b9c8a838 100644
--- a/CefSharp/DependencyChecker.cs
+++ b/CefSharp/DependencyChecker.cs
@@ -68,9 +68,19 @@ namespace CefSharp
public static string[] CefSharpDependencies =
{
"CefSharp.Core.dll",
- "CefSharp.dll",
+ "CefSharp.dll"
+ };
+
+ ///
+ /// List of CefSharp.BrowserSubprocess.exe dependencies.
+ ///
+ public static string[] BrowserSubprocessDependencies =
+ {
"CefSharp.BrowserSubprocess.Core.dll",
- "CefSharp.BrowserSubprocess.exe"
+ "CefSharp.Core.dll",
+ "CefSharp.dll",
+ "icudtl.dat",
+ "libcef.dll"
};
///
@@ -81,64 +91,44 @@ namespace CefSharp
/// Is loading of pack files disabled?
/// path to check for dependencies
///
+ /// The path to a separate executable that will be launched for sub-processes.
/// The locale pack file e.g.
/// List of missing dependencies, if all present an empty List will be returned
- public static List CheckDependencies(bool checkOptional, bool packLoadingDisabled, string path, string resourcesDirPath, string localePackFile = LocalesPackFile)
+ public static List CheckDependencies(bool checkOptional, bool packLoadingDisabled, string path, string resourcesDirPath, string browserSubProcessPath, string localePackFile = LocalesPackFile)
{
var missingDependencies = new List();
- //Loop through Cef dependencies and add to list if not found
- foreach (var cefDependency in CefDependencies)
- {
- var dependencyPath = Path.Combine(path, cefDependency);
-
- if (!File.Exists(dependencyPath))
- {
- missingDependencies.Add(cefDependency);
- }
- }
+ missingDependencies.AddRange(CheckDependencyList(path, CefDependencies));
if (!packLoadingDisabled)
{
- //Loop through Cef Resources and add to list if not found
- foreach (var cefResource in CefResources)
- {
- var resourcePath = Path.Combine(resourcesDirPath, cefResource);
-
- if (!File.Exists(resourcePath))
- {
- missingDependencies.Add(cefResource);
- }
- }
+ missingDependencies.AddRange(CheckDependencyList(resourcesDirPath, CefResources));
}
if (checkOptional)
{
- //Loop through Cef Optional dependencies and add to list if not found
- foreach (var cefDependency in CefOptionalDependencies)
- {
- var dependencyPath = Path.Combine(path, cefDependency);
-
- if (!File.Exists(dependencyPath))
- {
- missingDependencies.Add(cefDependency);
- }
- }
+ missingDependencies.AddRange(CheckDependencyList(path, CefOptionalDependencies));
}
- // Loop through CefSharp dependencies and add to list if not found
- foreach (var cefSharpDependency in CefSharpDependencies)
+ missingDependencies.AddRange(CheckDependencyList(path, CefSharpDependencies));
+
+ if (!File.Exists(browserSubProcessPath))
{
- var dependencyPath = Path.Combine(path, cefSharpDependency);
-
- if (!File.Exists(dependencyPath))
- {
- missingDependencies.Add(cefSharpDependency);
- }
+ missingDependencies.Add(browserSubProcessPath);
}
- //If path path is not rooted (doesn't start with a drive letter + folder)
- //then make it relative to the executing assembly.
+ var browserSubprocessDir = Path.GetDirectoryName(browserSubProcessPath);
+ if (browserSubprocessDir == null)
+ {
+ missingDependencies.AddRange(BrowserSubprocessDependencies);
+ }
+ else
+ {
+ missingDependencies.AddRange(CheckDependencyList(browserSubprocessDir, BrowserSubprocessDependencies));
+ }
+
+ // If path is not rooted (doesn't start with a drive letter + folder)
+ // then make it relative to the executing assembly.
var localePath = Path.IsPathRooted(localePackFile) ? localePackFile : Path.Combine(path, localePackFile);
if (!File.Exists(localePath))
@@ -149,6 +139,28 @@ namespace CefSharp
return missingDependencies;
}
+ ///
+ /// Loop through dependencies and add to the returned missing dependency list if not found.
+ ///
+ /// The directory of the dependencies, or the current directory if null.
+ /// The dependencies to check.
+ ///
+ private static List CheckDependencyList(string dir, IEnumerable files)
+ {
+ var missingDependencies = new List();
+
+ foreach (var file in files)
+ {
+ var filePath = dir != null ? Path.Combine(dir, file) : file;
+ if (!File.Exists(filePath))
+ {
+ missingDependencies.Add(filePath);
+ }
+ }
+
+ return missingDependencies;
+ }
+
///
/// Checks if all Cef and CefSharp dependencies were found relative to the Executing Assembly.
/// Shortcut method that calls , throws an Exception if not files are missing.
@@ -157,8 +169,9 @@ namespace CefSharp
/// The path to the locales directory, if empty locales\ will be used.
/// The path to the resources directory, if empty the Executing Assembly path is used.
/// Is loading of pack files disabled?
+ /// The path to a separate executable that will be launched for sub-processes.
/// Throw when not all dependencies are present
- public static void AssertAllDependenciesPresent(string locale, string localesDirPath, string resourcesDirPath, bool packLoadingDisabled)
+ public static void AssertAllDependenciesPresent(string locale, string localesDirPath, string resourcesDirPath, bool packLoadingDisabled, string browserSubProcessPath)
{
var executingAssembly = Assembly.GetExecutingAssembly();
@@ -179,7 +192,7 @@ namespace CefSharp
resourcesDirPath = path;
}
- var missingDependencies = CheckDependencies(true, packLoadingDisabled, path, resourcesDirPath, Path.Combine(localesDirPath, locale + ".pak"));
+ var missingDependencies = CheckDependencies(true, packLoadingDisabled, path, resourcesDirPath, browserSubProcessPath, Path.Combine(localesDirPath, locale + ".pak"));
if (missingDependencies.Count > 0)
{