mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-06 04:00:07 +00:00
NetCore - Initializer additional checks to locate libcef.dll
- When running from a library with no RuntimeIdentifier specified, check relative to CefSharp.Core.dll in runtimes folder
This commit is contained in:
@@ -34,7 +34,7 @@ namespace CefSharp
|
||||
//https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.getentryassembly?view=net-5.0
|
||||
if (executingAssembly == null)
|
||||
{
|
||||
currentFolder = Path.GetDirectoryName(typeof(Initializer).Assembly.Location);
|
||||
currentFolder = GetCefSharpCoreAssemblyLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -66,6 +66,16 @@ namespace CefSharp
|
||||
var arch = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
|
||||
var archFolder = $"runtimes\\win-{arch}\\native";
|
||||
libCefPath = Path.Combine(currentFolder, archFolder, "libcef.dll");
|
||||
|
||||
if (!File.Exists(libCefPath))
|
||||
{
|
||||
// For cases where the library is dynamically loaded and no RuntimeIdentifier
|
||||
// specified, attempt to locate libcef.dll next to CefSharp.Core.dll
|
||||
currentFolder = GetCefSharpCoreAssemblyLocation();
|
||||
|
||||
libCefPath = Path.Combine(currentFolder, archFolder, "libcef.dll");
|
||||
}
|
||||
|
||||
if (File.Exists(libCefPath))
|
||||
{
|
||||
LibCefLoaded = NativeLibrary.TryLoad(libCefPath, out IntPtr handle);
|
||||
@@ -86,5 +96,10 @@ namespace CefSharp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetCefSharpCoreAssemblyLocation()
|
||||
{
|
||||
return Path.GetDirectoryName(typeof(Initializer).Assembly.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user