Skip to content

Commit 24e516d

Browse files
committed
CefSharp.MinimalExample.sln - Add AnyCPU Solution Platform
1 parent 6178235 commit 24e516d

File tree

7 files changed

+158
-1
lines changed

7 files changed

+158
-1
lines changed

CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2020
<NuGetPackageImportStamp>
2121
</NuGetPackageImportStamp>
22+
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
2223
</PropertyGroup>
2324
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
2425
<DebugSymbols>true</DebugSymbols>
@@ -60,6 +61,28 @@
6061
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
6162
<Prefer32Bit>false</Prefer32Bit>
6263
</PropertyGroup>
64+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
65+
<DebugSymbols>true</DebugSymbols>
66+
<OutputPath>bin\AnyCPU\Debug\net452\</OutputPath>
67+
<DefineConstants>DEBUG;TRACE;ANYCPU</DefineConstants>
68+
<DebugType>full</DebugType>
69+
<PlatformTarget>AnyCPU</PlatformTarget>
70+
<LangVersion>7.3</LangVersion>
71+
<ErrorReport>prompt</ErrorReport>
72+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
73+
<Prefer32Bit>false</Prefer32Bit>
74+
</PropertyGroup>
75+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
76+
<OutputPath>bin\AnyCPU\Release\net452\</OutputPath>
77+
<DefineConstants>TRACE;ANYCPU</DefineConstants>
78+
<Optimize>true</Optimize>
79+
<DebugType>pdbonly</DebugType>
80+
<PlatformTarget>AnyCPU</PlatformTarget>
81+
<LangVersion>7.3</LangVersion>
82+
<ErrorReport>prompt</ErrorReport>
83+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
84+
<Prefer32Bit>false</Prefer32Bit>
85+
</PropertyGroup>
6386
<PropertyGroup>
6487
<ApplicationManifest>app.manifest</ApplicationManifest>
6588
</PropertyGroup>

CefSharp.MinimalExample.OffScreen/Program.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public class Program
1717

1818
public static int Main(string[] args)
1919
{
20+
#if ANYCPU
21+
//Only required for PlatformTarget of AnyCPU
22+
AppDomain.CurrentDomain.AssemblyResolve += Resolver;
23+
#endif
24+
2025
const string testUrl = "https://www.google.com/";
2126

2227
Console.WriteLine("This example application will load {0}, take a screenshot, and save it to your desktop.", testUrl);
@@ -104,5 +109,26 @@ private static void BrowserLoadingStateChanged(object sender, LoadingStateChange
104109
});
105110
}
106111
}
112+
113+
// Will attempt to load missing assembly from either x86 or x64 subdir
114+
//when PlatformTarget is AnyCPU
115+
#if ANYCPU
116+
private static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args)
117+
{
118+
if (args.Name.StartsWith("CefSharp.Core.Runtime"))
119+
{
120+
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
121+
string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
122+
Environment.Is64BitProcess ? "x64" : "x86",
123+
assemblyName);
124+
125+
return File.Exists(archSpecificPath)
126+
? System.Reflection.Assembly.LoadFile(archSpecificPath)
127+
: null;
128+
}
129+
130+
return null;
131+
}
132+
#endif
107133
}
108134
}

CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2828
<NuGetPackageImportStamp>
2929
</NuGetPackageImportStamp>
30+
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
3031
</PropertyGroup>
3132
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
3233
<PlatformTarget>x64</PlatformTarget>
@@ -51,6 +52,21 @@
5152
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
5253
<Prefer32Bit>false</Prefer32Bit>
5354
</PropertyGroup>
55+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
56+
<DebugSymbols>true</DebugSymbols>
57+
<OutputPath>bin\AnyCPU\Debug\net452\</OutputPath>
58+
<PlatformTarget>AnyCPU</PlatformTarget>
59+
<LangVersion>7.3</LangVersion>
60+
<DefineConstants>DEBUG;TRACE;ANYCPU</DefineConstants>
61+
<Prefer32Bit>false</Prefer32Bit>
62+
</PropertyGroup>
63+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
64+
<OutputPath>bin\AnyCPU\Release\net452\</OutputPath>
65+
<PlatformTarget>AnyCPU</PlatformTarget>
66+
<LangVersion>7.3</LangVersion>
67+
<DefineConstants>TRACE;ANYCPU</DefineConstants>
68+
<Prefer32Bit>false</Prefer32Bit>
69+
</PropertyGroup>
5470
<PropertyGroup>
5571
<ApplicationManifest>app.manifest</ApplicationManifest>
5672
</PropertyGroup>

CefSharp.MinimalExample.WinForms/Program.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public class Program
1414
[STAThread]
1515
public static int Main(string[] args)
1616
{
17+
18+
#if ANYCPU
19+
//Only required for PlatformTarget of AnyCPU
20+
AppDomain.CurrentDomain.AssemblyResolve += Resolver;
21+
#endif
22+
1723
//For Windows 7 and above, best to include relevant app.manifest entries as well
1824
Cef.EnableHighDPISupport();
1925

@@ -50,5 +56,26 @@ public static int Main(string[] args)
5056

5157
return 0;
5258
}
59+
60+
// Will attempt to load missing assembly from either x86 or x64 subdir
61+
//when PlatformTarget is AnyCPU
62+
#if ANYCPU
63+
private static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args)
64+
{
65+
if (args.Name.StartsWith("CefSharp.Core.Runtime"))
66+
{
67+
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
68+
string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
69+
Environment.Is64BitProcess ? "x64" : "x86",
70+
assemblyName);
71+
72+
return File.Exists(archSpecificPath)
73+
? System.Reflection.Assembly.LoadFile(archSpecificPath)
74+
: null;
75+
}
76+
77+
return null;
78+
}
79+
#endif
5380
}
5481
}

CefSharp.MinimalExample.Wpf/App.xaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public partial class App : Application
99
{
1010
public App()
1111
{
12+
#if ANYCPU
13+
//Only required for PlatformTarget of AnyCPU
14+
AppDomain.CurrentDomain.AssemblyResolve += Resolver;
15+
#endif
1216
var settings = new CefSettings()
1317
{
1418
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
@@ -37,5 +41,24 @@ public App()
3741
//Perform dependency check to make sure all relevant resources are in our output directory.
3842
Cef.Initialize(settings, performDependencyCheck: dependencyCheck, browserProcessHandler: null);
3943
}
44+
45+
#if ANYCPU
46+
private static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args)
47+
{
48+
if (args.Name.StartsWith("CefSharp.Core.Runtime"))
49+
{
50+
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
51+
string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
52+
Environment.Is64BitProcess ? "x64" : "x86",
53+
assemblyName);
54+
55+
return File.Exists(archSpecificPath)
56+
? System.Reflection.Assembly.LoadFile(archSpecificPath)
57+
: null;
58+
}
59+
60+
return null;
61+
}
62+
#endif
4063
}
4164
}

CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2222
<NuGetPackageImportStamp>
2323
</NuGetPackageImportStamp>
24+
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
2425
</PropertyGroup>
2526
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
2627
<DebugSymbols>true</DebugSymbols>
@@ -62,6 +63,28 @@
6263
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
6364
<Prefer32Bit>false</Prefer32Bit>
6465
</PropertyGroup>
66+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
67+
<DebugSymbols>true</DebugSymbols>
68+
<OutputPath>bin\AnyCPU\Debug\net452\</OutputPath>
69+
<DefineConstants>DEBUG;TRACE;ANYCPU</DefineConstants>
70+
<DebugType>full</DebugType>
71+
<PlatformTarget>AnyCPU</PlatformTarget>
72+
<LangVersion>7.3</LangVersion>
73+
<ErrorReport>prompt</ErrorReport>
74+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
75+
<Prefer32Bit>false</Prefer32Bit>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
78+
<OutputPath>bin\AnyCPU\Release\net452\</OutputPath>
79+
<DefineConstants>TRACE;ANYCPU</DefineConstants>
80+
<Optimize>true</Optimize>
81+
<DebugType>pdbonly</DebugType>
82+
<PlatformTarget>AnyCPU</PlatformTarget>
83+
<LangVersion>7.3</LangVersion>
84+
<ErrorReport>prompt</ErrorReport>
85+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
86+
<Prefer32Bit>false</Prefer32Bit>
87+
</PropertyGroup>
6588
<PropertyGroup>
6689
<ApplicationIcon>chromium-256.ico</ApplicationIcon>
6790
</PropertyGroup>

CefSharp.MinimalExample.sln

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30907.101
5+
MinimumVisualStudioVersion = 10.0.40219.1
46
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.MinimalExample.Wpf", "CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.csproj", "{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}"
57
EndProject
68
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.MinimalExample.WinForms", "CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.csproj", "{C043FFF7-5F71-4FFC-989A-E09E18548589}"
@@ -9,32 +11,46 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.MinimalExample.Off
911
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
1215
Debug|x64 = Debug|x64
1316
Debug|x86 = Debug|x86
17+
Release|Any CPU = Release|Any CPU
1418
Release|x64 = Release|x64
1519
Release|x86 = Release|x86
1620
EndGlobalSection
1721
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
1824
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x64.ActiveCfg = Debug|x64
1925
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x64.Build.0 = Debug|x64
2026
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x86.ActiveCfg = Debug|x86
2127
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x86.Build.0 = Debug|x86
28+
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|Any CPU.Build.0 = Release|Any CPU
2230
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x64.ActiveCfg = Release|x64
2331
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x64.Build.0 = Release|x64
2432
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x86.ActiveCfg = Release|x86
2533
{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x86.Build.0 = Release|x86
34+
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|Any CPU.Build.0 = Debug|Any CPU
2636
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x64.ActiveCfg = Debug|x64
2737
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x64.Build.0 = Debug|x64
2838
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x86.ActiveCfg = Debug|x86
2939
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x86.Build.0 = Debug|x86
40+
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|Any CPU.Build.0 = Release|Any CPU
3042
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x64.ActiveCfg = Release|x64
3143
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x64.Build.0 = Release|x64
3244
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x86.ActiveCfg = Release|x86
3345
{C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x86.Build.0 = Release|x86
46+
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|Any CPU.Build.0 = Debug|Any CPU
3448
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x64.ActiveCfg = Debug|x64
3549
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x64.Build.0 = Debug|x64
3650
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x86.ActiveCfg = Debug|x86
3751
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x86.Build.0 = Debug|x86
52+
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|Any CPU.Build.0 = Release|Any CPU
3854
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|x64.ActiveCfg = Release|x64
3955
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|x64.Build.0 = Release|x64
4056
{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|x86.ActiveCfg = Release|x86
@@ -43,4 +59,7 @@ Global
4359
GlobalSection(SolutionProperties) = preSolution
4460
HideSolutionNode = FALSE
4561
EndGlobalSection
62+
GlobalSection(ExtensibilityGlobals) = postSolution
63+
SolutionGuid = {5903BE76-C30A-4AA3-AEBA-48B3138EC241}
64+
EndGlobalSection
4665
EndGlobal

0 commit comments

Comments
 (0)