mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
2b8f1f4b1a
Assembly.LoadFile wasn't working for some reason, switch to using AppDomain.CurrentDomain.AssemblyResolve Only attach to even if file doesn't exist within the current project Follow up to https://github.com/cefsharp/CefSharp/commit/6f4fe5e12ad81297218da0d8e43a629af77879cc#diff-2bf0d9d6d03aa9b6327ddacd7d82698462654236f558191054e7ed274b6addd9
74 lines
2.9 KiB
C#
74 lines
2.9 KiB
C#
// Copyright © 2013 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Runtime.CompilerServices;
|
|
using CefSharp.RenderProcess;
|
|
|
|
namespace CefSharp.BrowserSubprocess
|
|
{
|
|
/// <summary>
|
|
/// When implementing your own BrowserSubprocess
|
|
/// - For Full .Net use <see cref="WcfBrowserSubprocessExecutable"/>
|
|
/// - For .Net Core use <see cref="BrowserSubprocessExecutable"/> (No WCF Support)
|
|
/// - Include an app.manifest with the dpi/compatability sections, this is required (this project contains the relevant).
|
|
/// - If you are targeting x86/Win32 then you should set /LargeAddressAware (https://docs.microsoft.com/en-us/cpp/build/reference/largeaddressaware?view=vs-2017)
|
|
/// </summary>
|
|
public class Program
|
|
{
|
|
public static int Main(string[] args)
|
|
{
|
|
Debug.WriteLine("BrowserSubprocess starting up with command line: " + string.Join("\n", args));
|
|
|
|
if(!File.Exists("CefSharp.dll"))
|
|
{
|
|
//For publshing ClickOnce AnyCPU CefSharp.dll isn't included in the x64 build
|
|
//and the BrowserSubprocess fails to launch as a result.
|
|
//As a temp workaround load the file from the parent directory.
|
|
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;
|
|
}
|
|
|
|
return MainInternal(args);
|
|
}
|
|
|
|
private static System.Reflection.Assembly AssemblyResolve(object sender, ResolveEventArgs args)
|
|
{
|
|
if (args.Name.StartsWith("CefSharp.dll"))
|
|
{
|
|
AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolve;
|
|
|
|
//Load from parent directory for AnyCPU Clickonce
|
|
if (File.Exists("..\\CefSharp.dll"))
|
|
{
|
|
return System.Reflection.Assembly.LoadFile("..\\CefSharp.dll");
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
|
private static int MainInternal(string[] args)
|
|
{
|
|
SubProcess.EnableHighDPISupport();
|
|
|
|
//Add your own custom implementation of IRenderProcessHandler here
|
|
IRenderProcessHandler handler = null;
|
|
|
|
//The WcfBrowserSubprocessExecutable provides BrowserSubProcess functionality
|
|
//specific to CefSharp, WCF support (required for Sync JSB) will optionally be
|
|
//enabled if the CefSharpArguments.WcfEnabledArgument command line arg is present
|
|
//For .Net Core use BrowserSubprocessExecutable as there is no WCF support
|
|
var browserProcessExe = new WcfBrowserSubprocessExecutable();
|
|
var result = browserProcessExe.Main(args, handler);
|
|
|
|
Debug.WriteLine("BrowserSubprocess shutting down.");
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|