diff --git a/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj b/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj index 5d080e6..f9be5d3 100644 --- a/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj +++ b/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj @@ -19,6 +19,7 @@ ..\ + true true @@ -60,6 +61,28 @@ MinimumRecommendedRules.ruleset false + + true + bin\AnyCPU\Debug\net452\ + DEBUG;TRACE;ANYCPU + full + AnyCPU + 7.3 + prompt + MinimumRecommendedRules.ruleset + false + + + bin\AnyCPU\Release\net452\ + TRACE;ANYCPU + true + pdbonly + AnyCPU + 7.3 + prompt + MinimumRecommendedRules.ruleset + false + app.manifest diff --git a/CefSharp.MinimalExample.OffScreen/Program.cs b/CefSharp.MinimalExample.OffScreen/Program.cs index bf34850..c165be2 100644 --- a/CefSharp.MinimalExample.OffScreen/Program.cs +++ b/CefSharp.MinimalExample.OffScreen/Program.cs @@ -17,6 +17,11 @@ namespace CefSharp.MinimalExample.OffScreen public static int Main(string[] args) { +#if ANYCPU + //Only required for PlatformTarget of AnyCPU + AppDomain.CurrentDomain.AssemblyResolve += Resolver; +#endif + const string testUrl = "https://www.google.com/"; Console.WriteLine("This example application will load {0}, take a screenshot, and save it to your desktop.", testUrl); @@ -104,5 +109,26 @@ namespace CefSharp.MinimalExample.OffScreen }); } } + + // Will attempt to load missing assembly from either x86 or x64 subdir + //when PlatformTarget is AnyCPU +#if ANYCPU + private static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args) + { + if (args.Name.StartsWith("CefSharp.Core.Runtime")) + { + string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll"; + string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, + Environment.Is64BitProcess ? "x64" : "x86", + assemblyName); + + return File.Exists(archSpecificPath) + ? System.Reflection.Assembly.LoadFile(archSpecificPath) + : null; + } + + return null; + } +#endif } } diff --git a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj index 5dea347..20f3e48 100644 --- a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj +++ b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj @@ -27,6 +27,7 @@ ..\ + true x64 @@ -51,6 +52,21 @@ MinimumRecommendedRules.ruleset false + + true + bin\AnyCPU\Debug\net452\ + AnyCPU + 7.3 + DEBUG;TRACE;ANYCPU + false + + + bin\AnyCPU\Release\net452\ + AnyCPU + 7.3 + TRACE;ANYCPU + false + app.manifest diff --git a/CefSharp.MinimalExample.WinForms/Program.cs b/CefSharp.MinimalExample.WinForms/Program.cs index b74f530..c949b53 100644 --- a/CefSharp.MinimalExample.WinForms/Program.cs +++ b/CefSharp.MinimalExample.WinForms/Program.cs @@ -14,6 +14,12 @@ namespace CefSharp.MinimalExample.WinForms [STAThread] public static int Main(string[] args) { + +#if ANYCPU + //Only required for PlatformTarget of AnyCPU + AppDomain.CurrentDomain.AssemblyResolve += Resolver; +#endif + //For Windows 7 and above, best to include relevant app.manifest entries as well Cef.EnableHighDPISupport(); @@ -50,5 +56,26 @@ namespace CefSharp.MinimalExample.WinForms return 0; } + + // Will attempt to load missing assembly from either x86 or x64 subdir + //when PlatformTarget is AnyCPU +#if ANYCPU + private static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args) + { + if (args.Name.StartsWith("CefSharp.Core.Runtime")) + { + string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll"; + string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, + Environment.Is64BitProcess ? "x64" : "x86", + assemblyName); + + return File.Exists(archSpecificPath) + ? System.Reflection.Assembly.LoadFile(archSpecificPath) + : null; + } + + return null; + } +#endif } } diff --git a/CefSharp.MinimalExample.Wpf/App.xaml.cs b/CefSharp.MinimalExample.Wpf/App.xaml.cs index b8b484e..6436121 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml.cs +++ b/CefSharp.MinimalExample.Wpf/App.xaml.cs @@ -9,6 +9,10 @@ namespace CefSharp.MinimalExample.Wpf { public App() { +#if ANYCPU + //Only required for PlatformTarget of AnyCPU + AppDomain.CurrentDomain.AssemblyResolve += Resolver; +#endif var settings = new CefSettings() { //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data @@ -37,5 +41,24 @@ namespace CefSharp.MinimalExample.Wpf //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(settings, performDependencyCheck: dependencyCheck, browserProcessHandler: null); } + +#if ANYCPU + private static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args) + { + if (args.Name.StartsWith("CefSharp.Core.Runtime")) + { + string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll"; + string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, + Environment.Is64BitProcess ? "x64" : "x86", + assemblyName); + + return File.Exists(archSpecificPath) + ? System.Reflection.Assembly.LoadFile(archSpecificPath) + : null; + } + + return null; + } +#endif } } diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj index 52634e7..e626534 100644 --- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj +++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj @@ -21,6 +21,7 @@ ..\ + true true @@ -62,6 +63,28 @@ MinimumRecommendedRules.ruleset false + + true + bin\AnyCPU\Debug\net452\ + DEBUG;TRACE;ANYCPU + full + AnyCPU + 7.3 + prompt + MinimumRecommendedRules.ruleset + false + + + bin\AnyCPU\Release\net452\ + TRACE;ANYCPU + true + pdbonly + AnyCPU + 7.3 + prompt + MinimumRecommendedRules.ruleset + false + chromium-256.ico diff --git a/CefSharp.MinimalExample.sln b/CefSharp.MinimalExample.sln index 1f0bfc2..d1810f2 100644 --- a/CefSharp.MinimalExample.sln +++ b/CefSharp.MinimalExample.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30907.101 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.MinimalExample.Wpf", "CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.csproj", "{BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}" EndProject 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 EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x64.ActiveCfg = Debug|x64 {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x64.Build.0 = Debug|x64 {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x86.ActiveCfg = Debug|x86 {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Debug|x86.Build.0 = Debug|x86 + {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|Any CPU.Build.0 = Release|Any CPU {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x64.ActiveCfg = Release|x64 {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x64.Build.0 = Release|x64 {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x86.ActiveCfg = Release|x86 {BE4C3AD0-8DA2-4246-8C63-EEEB7DC197BE}.Release|x86.Build.0 = Release|x86 + {C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|Any CPU.Build.0 = Debug|Any CPU {C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x64.ActiveCfg = Debug|x64 {C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x64.Build.0 = Debug|x64 {C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x86.ActiveCfg = Debug|x86 {C043FFF7-5F71-4FFC-989A-E09E18548589}.Debug|x86.Build.0 = Debug|x86 + {C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|Any CPU.Build.0 = Release|Any CPU {C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x64.ActiveCfg = Release|x64 {C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x64.Build.0 = Release|x64 {C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x86.ActiveCfg = Release|x86 {C043FFF7-5F71-4FFC-989A-E09E18548589}.Release|x86.Build.0 = Release|x86 + {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x64.ActiveCfg = Debug|x64 {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x64.Build.0 = Debug|x64 {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x86.ActiveCfg = Debug|x86 {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Debug|x86.Build.0 = Debug|x86 + {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|Any CPU.Build.0 = Release|Any CPU {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|x64.ActiveCfg = Release|x64 {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|x64.Build.0 = Release|x64 {A4DEB90C-A529-4A93-ACE3-226A39EFCB00}.Release|x86.ActiveCfg = Release|x86 @@ -43,4 +59,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5903BE76-C30A-4AA3-AEBA-48B3138EC241} + EndGlobalSection EndGlobal