diff --git a/CefSharp.BrowserSubprocess.Core/BrowserSubprocessExecutable.h b/CefSharp.BrowserSubprocess.Core/BrowserSubprocessExecutable.h index 7d624dc590..f4f9ca45be 100644 --- a/CefSharp.BrowserSubprocess.Core/BrowserSubprocessExecutable.h +++ b/CefSharp.BrowserSubprocess.Core/BrowserSubprocessExecutable.h @@ -28,12 +28,12 @@ namespace CefSharp } +#ifdef NETCOREAPP /// /// This function should be called from the application entry point function (typically Program.Main) /// to execute a secondary process e.g. gpu, renderer, utility /// This overload is specifically used for .Net Core. For hosting your own BrowserSubProcess /// it's preferable to use the Main method provided by this class. - /// - Obtains the command line args via a call to Environment::GetCommandLineArgs /// /// /// If called for the browser process (identified by no "type" command-line value) it will return immediately @@ -45,6 +45,7 @@ namespace CefSharp auto subProcess = gcnew BrowserSubprocessExecutable(); return subProcess->Main(args, nullptr); } +#endif /// /// This function should be called from the application entry point function (typically Program.Main) diff --git a/CefSharp.BrowserSubprocess.Core/WcfBrowserSubprocessExecutable.h b/CefSharp.BrowserSubprocess.Core/WcfBrowserSubprocessExecutable.h index 761e5344f1..18291ddd44 100644 --- a/CefSharp.BrowserSubprocess.Core/WcfBrowserSubprocessExecutable.h +++ b/CefSharp.BrowserSubprocess.Core/WcfBrowserSubprocessExecutable.h @@ -31,6 +31,24 @@ namespace CefSharp { } + + /// + /// This function should be called from the application entry point function (typically Program.Main) + /// to execute a secondary process e.g. gpu, renderer, utility + /// This overload is specifically used for .Net 4.x. For hosting your own BrowserSubProcess + /// it's preferable to use the Main method provided by this class. + /// + /// + /// If called for the browser process (identified by no "type" command-line value) it will return immediately + /// with a value of -1. If called for a recognized secondary process it will block until the process should exit + /// and then return the process exit code. + /// ^ args) + { + auto subProcess = gcnew WcfBrowserSubprocessExecutable(); + return subProcess->Main(args, nullptr); + } + protected: SubProcess^ GetSubprocess(IEnumerable^ args, int parentProcessId, IRenderProcessHandler^ handler) override { diff --git a/CefSharp.Core/BrowserSubprocess/SelfHost.cs b/CefSharp.Core/BrowserSubprocess/SelfHost.cs index 76355bee00..f97c16eafa 100644 --- a/CefSharp.Core/BrowserSubprocess/SelfHost.cs +++ b/CefSharp.Core/BrowserSubprocess/SelfHost.cs @@ -77,12 +77,13 @@ public static int Main(string[] args) browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll"); } var browserSubprocessDll = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(browserSubprocessDllPath); + var browserSubprocessExecutableType = browserSubprocessDll.GetType("CefSharp.BrowserSubprocess.BrowserSubprocessExecutable"); #else var browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll"); var browserSubprocessDll = System.Reflection.Assembly.LoadFrom(browserSubprocessDllPath); - + var browserSubprocessExecutableType = browserSubprocessDll.GetType("CefSharp.BrowserSubprocess.WcfBrowserSubprocessExecutable"); #endif - var browserSubprocessExecutableType = browserSubprocessDll.GetType("CefSharp.BrowserSubprocess.BrowserSubprocessExecutable"); + var browserSubprocessExecutable = Activator.CreateInstance(browserSubprocessExecutableType); var mainMethod = browserSubprocessExecutableType.GetMethod("MainSelfHost", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);