Skip to content

Commit

Permalink
Fixed the mono and netframework directory retrieval issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrohanea committed Oct 30, 2024
1 parent 5ddb2c7 commit 008dad7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Whisper.net/LibraryLoader/NativeLibraryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@ private static bool IsRuntimeSupported(RuntimeLibrary runtime, string platform,
_ => throw new PlatformNotSupportedException($"Unsupported OS platform, architecture: {RuntimeInformation.OSArchitecture}")
};

var assemblyLocation = typeof(NativeLibraryLoader).Assembly.Location;
var environmentAppStartLocation = Environment.GetCommandLineArgs()[0];
// NetFramework and Mono will crash if we try to get the directory of an empty string.
var assemblySearchPaths = new[]
{
AppDomain.CurrentDomain.RelativeSearchPath,
AppDomain.CurrentDomain.BaseDirectory,
Path.GetDirectoryName(typeof(NativeLibraryLoader).Assembly.Location),
Path.GetDirectoryName(Environment.GetCommandLineArgs()[0])
}.Where(it => !string.IsNullOrEmpty(it));
string.IsNullOrWhiteSpace(assemblyLocation) ? null : Path.GetDirectoryName(assemblyLocation),
string.IsNullOrWhiteSpace(environmentAppStartLocation) ? null : Path.GetDirectoryName(environmentAppStartLocation)
}.Where(it => !string.IsNullOrEmpty(it)).Distinct();

foreach (var library in RuntimeOptions.Instance.RuntimeLibraryOrder)
{
Expand Down

0 comments on commit 008dad7

Please sign in to comment.