From b5118b5646fa173afc8ea6ae8eef6eca01e2e5ec Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Tue, 12 Jan 2021 10:47:09 +1000 Subject: [PATCH] Net Core - Fix BrowserSubProcess.SelfHost path lookup - Add Initializer.BrowserSubProcessCorePath which is calculated the same as BrowserSubProcessPath - Update SelfHost to use new path then fallback to old path. Details in https://github.com/cefsharp/CefSharp/issues/3197#issuecomment-757819840 --- CefSharp.Core/BrowserSubprocess/SelfHost.cs | 9 ++++++++- CefSharp.Core/Initializer.cs | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CefSharp.Core/BrowserSubprocess/SelfHost.cs b/CefSharp.Core/BrowserSubprocess/SelfHost.cs index 287293521..33e966dd2 100644 --- a/CefSharp.Core/BrowserSubprocess/SelfHost.cs +++ b/CefSharp.Core/BrowserSubprocess/SelfHost.cs @@ -72,11 +72,18 @@ public class SelfHost 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); diff --git a/CefSharp.Core/Initializer.cs b/CefSharp.Core/Initializer.cs index 38bf602e5..d21085332 100644 --- a/CefSharp.Core/Initializer.cs +++ b/CefSharp.Core/Initializer.cs @@ -22,6 +22,7 @@ namespace CefSharp 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() @@ -49,6 +50,8 @@ namespace CefSharp if (LibCefLoaded) { BrowserSubProcessPath = Path.Combine(currentFolder, archFolder, "CefSharp.BrowserSubprocess.exe"); + BrowserSubProcessCorePath = Path.Combine(currentFolder, archFolder, "CefSharp.BrowserSubprocess.Core.dll"); + LibCefPath = libCefPath; LibCefHandle = handle; }