Skip to content

Commit 0a5d916

Browse files
committed
Update target frameworks
1 parent fb81c70 commit 0a5d916

6 files changed

Lines changed: 50 additions & 14 deletions

File tree

CefSharp.OutOfProcess.BrowserProcess/BrowserProcessHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected override void OnContextInitialized()
5555

5656
_jsonRpc.AddLocalRpcMethod("CreateBrowser", (Action<int, string, int>)delegate (int parentHwnd, string url, int id)
5757
{
58-
Debugger.Break();
58+
//Debugger.Break();
5959

6060
_ = CefThread.ExecuteOnUiThread(() =>
6161
{

CefSharp.OutOfProcess.BrowserProcess/CefSharp.OutOfProcess.BrowserProcess.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
66
<PlatformTarget>x64</PlatformTarget>
77
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
88
<SelfContained>false</SelfContained>
99
<ApplicationManifest>app.manifest</ApplicationManifest>
10-
<CefSharpBuildAction>NoAction</CefSharpBuildAction>
10+
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
11+
<!--<CefSharpBuildAction>NoAction</CefSharpBuildAction>-->
1112
</PropertyGroup>
1213

1314
<ItemGroup>
14-
<PackageReference Include="CefSharp.Common.NETCore" Version="102.0.90-RCI4501" />
1515
<PackageReference Include="PInvoke.Kernel32" Version="0.7.104" />
1616
<PackageReference Include="StreamJsonRpc" Version="2.11.35" />
1717
</ItemGroup>
1818

19+
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
20+
<PackageReference Include="CefSharp.Common" Version="102.0.90-RCI4501"/>
21+
</ItemGroup>
22+
23+
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
24+
<PackageReference Include="CefSharp.Common.NETCore" Version="102.0.90-RCI4501"/>
25+
</ItemGroup>
26+
1927
</Project>

CefSharp.OutOfProcess.BrowserProcess/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static int Main(string[] args)
1414
{
1515
Cef.EnableHighDPISupport();
1616

17-
Debugger.Launch();
17+
//Debugger.Launch();
1818

1919
var parentProcessId = int.Parse(CommandLineArgsParser.GetArgumentValue(args, "--parentProcessId"));
2020

CefSharp.OutOfProcess.Core/OutOfProcessHost.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace CefSharp.OutOfProcess
1010
{
1111
public class OutOfProcessHost : IDisposable
1212
{
13+
/// <summary>
14+
/// The CefSharp.OutOfProcess.BrowserProcess.exe name
15+
/// </summary>
16+
public const string HostExeName = "CefSharp.OutOfProcess.BrowserProcess.exe";
17+
1318
private Process _browserProcess;
1419
private JsonRpc _jsonRpc;
1520
private int _uiThreadId;
@@ -90,9 +95,21 @@ public void Dispose()
9095
_jsonRpc = null;
9196
}
9297

93-
public static Task<OutOfProcessHost> CreateAsync(string path = "CefSharp.OutOfProcess.BrowserProcess.exe")
98+
public static Task<OutOfProcessHost> CreateAsync(string path = HostExeName)
9499
{
95-
var host = new OutOfProcessHost(Path.GetFullPath(path));
100+
if(string.IsNullOrEmpty(path))
101+
{
102+
throw new ArgumentNullException(nameof(path));
103+
}
104+
105+
var fullPath = Path.GetFullPath(path);
106+
107+
if (!File.Exists(fullPath))
108+
{
109+
throw new FileNotFoundException("Unable to find Host executable.", path);
110+
}
111+
112+
var host = new OutOfProcessHost(fullPath);
96113

97114
host.Init();
98115

CefSharp.OutOfProcess.WinForms.Example/HostForm.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
using CefSharp.OutOfProcess;
2-
using System;
1+
using System;
2+
using System.IO;
33
using System.Windows.Forms;
44

55
namespace CefSharp.OutOfProcess.WinForms.Example
66
{
77
public partial class HostForm : Form
88
{
9+
#if DEBUG
10+
private string _buildType = "Debug";
11+
#else
12+
private string _buildType = "Release";
13+
#endif
14+
15+
#if NETCOREAPP3_1_OR_GREATER
16+
private string _targetFramework = "netcoreapp3.1";
17+
#else
18+
private string _targetFramework = "net462";
19+
#endif
920
private OutOfProcessHost _outOfProcessHost;
1021

1122
public HostForm()
@@ -25,7 +36,9 @@ private void HostFormOResize(object sender, EventArgs e)
2536

2637
private async void HostFormOnLoad(object sender, EventArgs e)
2738
{
28-
_outOfProcessHost = await OutOfProcessHost.CreateAsync();
39+
var outOfProcessHostPath = Path.GetFullPath($"..\\..\\..\\..\\..\\CefSharp.OutOfProcess.BrowserProcess\\bin\\{_buildType}\\{_targetFramework}");
40+
outOfProcessHostPath = Path.Combine(outOfProcessHostPath, OutOfProcessHost.HostExeName);
41+
_outOfProcessHost = await OutOfProcessHost.CreateAsync(outOfProcessHostPath);
2942

3043
var browser = new ChromiumWebBrowser(_outOfProcessHost, "https://github.com");
3144
browser.Dock = DockStyle.Fill;

CefSharp.OutOfProcess.WinForms/CefSharp.OutOfProcess.WinForms.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
55
<UseWindowsForms>true</UseWindowsForms>
66
</PropertyGroup>
77

@@ -16,9 +16,7 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<Compile Update="ChromiumWebBrowser.cs">
20-
<SubType>Component</SubType>
21-
</Compile>
19+
<Compile Update="ChromiumWebBrowser.cs" />
2220
</ItemGroup>
2321

2422
</Project>

0 commit comments

Comments
 (0)