1 year ago
#374086
Alex McIntosh
CefSharp - Published: Could not load file or assembly 'CefSharp.Core.Runtime.dll'
Using CefSharp.WinForms (NuGet Download) Version: 99.2.140
I've updated .csproj file to include
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
And updated the App.config file to inlcude:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="x86"/>
</assemblyBinding>
</runtime>
Using: Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.31.31103 Using: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.31.31103 (I've set the build to be explicity x86 & x64 which had the same results.)
I've built a couple of Solutions using CefSharp and they both have the same issue. They run perfectly from Visual Studios (Debug OR Release Mode). But, once I publish it. Bam.. "Could not load file or assembly 'CefSharp.Core.Runtime.dll'..."
Ughh, I'm stuck :( Sincerely; Alex.
PS. Here's my current Code in class Program. A 'Could not load file... 'CefSharp.Core.Runtime.. ' will occur when Build | Platform target: AnyCPU or x64. It will work if Platform targe set to x86
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static int Main(string[] args)
{
CefRuntime.SubscribeAnyCpuAssemblyResolver();
//For Windows 7 and above, best to include relevant app.manifest entries as well
Cef.EnableHighDPISupport();
var exitCode = CefSharp.BrowserSubprocess.SelfHost.Main(args);
if (exitCode >= 0)
{
return exitCode;
}
var settings = new CefSettings()
{
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"),
BrowserSubprocessPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
};
//Example of setting a command line argument
//Enables WebRTC
// - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access
// - CEF Doesn't currently support displaying a UI for media access permissions
//
//NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
settings.CefCommandLineArgs.Add("enable-media-stream");
//https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream
settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
//For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180)
settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing");
//Perform dependency check to make sure all relevant resources are in our output directory.
//IMPORTANT: MUST set performDependencyCheck false
Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
return 0;
}
}
I get the following.NET Runtime error
Application: InventoryDB.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException at CefSharp.Cef.EnableHighDPISupport() at InventoryDB.Program.Main(System.String[])
c#
publish
cefsharp
0 Answers
Your Answer