Skip to content

Commit

Permalink
Net Core - Fix BrowserSubProcess.SelfHost path lookup
Browse files Browse the repository at this point in the history
- Add Initializer.BrowserSubProcessCorePath which is calculated the same as BrowserSubProcessPath
- Update SelfHost to use new path then fallback to old path.

Details in #3197 (comment)
  • Loading branch information
amaitland committed Jan 12, 2021
1 parent bf8893a commit 83d960e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CefSharp.Core/BrowserSubprocess/SelfHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,18 @@ public static int Main(string[] args)
return -1;
}

var browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll");

#if NETCOREAPP
var browserSubprocessDllPath = Initializer.BrowserSubProcessCorePath;
if (!File.Exists(browserSubprocessDllPath))
{
browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll");
}
var browserSubprocessDll = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(browserSubprocessDllPath);
#else
var browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll");
var browserSubprocessDll = System.Reflection.Assembly.LoadFrom(browserSubprocessDllPath);

#endif
var browserSubprocessExecutableType = browserSubprocessDll.GetType("CefSharp.BrowserSubprocess.BrowserSubprocessExecutable");
var browserSubprocessExecutable = Activator.CreateInstance(browserSubprocessExecutableType);
Expand Down
3 changes: 3 additions & 0 deletions CefSharp.Core/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class Initializer
internal static bool LibCefLoaded { get; private set; }
internal static string LibCefPath { get; private set; }
internal static string BrowserSubProcessPath { get; private set; }
internal static string BrowserSubProcessCorePath { get; private set; }

[ModuleInitializer]
internal static void ModuleInitializer()
Expand Down Expand Up @@ -49,6 +50,8 @@ internal static void ModuleInitializer()
if (LibCefLoaded)
{
BrowserSubProcessPath = Path.Combine(currentFolder, archFolder, "CefSharp.BrowserSubprocess.exe");
BrowserSubProcessCorePath = Path.Combine(currentFolder, archFolder, "CefSharp.BrowserSubprocess.Core.dll");

LibCefPath = libCefPath;
LibCefHandle = handle;
}
Expand Down

0 comments on commit 83d960e

Please sign in to comment.