diff --git a/CueSDK.cs b/CueSDK.cs index 35f4bff..c6a1f34 100644 --- a/CueSDK.cs +++ b/CueSDK.cs @@ -25,6 +25,18 @@ namespace CUE.NET // ReSharper disable UnusedAutoPropertyAccessor.Global + /// + /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. + /// The first match will be used. + /// + public static List PossibleX86NativePaths { get; } = new List { "x86/CUESDK_2015.dll", "x86/CUESDK.dll" }; + + /// + /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. + /// The first match will be used. + /// + public static List PossibleX64NativePaths { get; } = new List { "x64/CUESDK_2015.dll", "x64/CUESDK.dll" }; + /// /// Indicates if the SDK is initialized and ready to use. /// diff --git a/Native/_CUESDK.cs b/Native/_CUESDK.cs index a99a083..256c7ea 100644 --- a/Native/_CUESDK.cs +++ b/Native/_CUESDK.cs @@ -2,7 +2,9 @@ // ReSharper disable UnusedMember.Global using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Runtime.InteropServices; using CUE.NET.Devices.Generic.Enums; using CUE.NET.Exceptions; @@ -20,7 +22,7 @@ namespace CUE.NET.Native /// Gets the loaded architecture (x64/x86). /// internal static string LoadedArchitecture { get; private set; } - + /// /// Reloads the SDK. /// @@ -35,8 +37,16 @@ namespace CUE.NET.Native if (_dllHandle != IntPtr.Zero) return; // HACK: Load library at runtime to support both, x86 and x64 with one managed dll - string dllPath = (LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/CUESDK_2015.dll"; - if (!File.Exists(dllPath)) throw new WrapperException($"Can't find the CUE-SDK at the expected location '{Path.GetFullPath(dllPath)}'"); + List possiblePathList = Environment.Is64BitProcess ? CueSDK.PossibleX64NativePaths : CueSDK.PossibleX86NativePaths; + string dllPath = null; + foreach (string path in possiblePathList) + if (File.Exists(path)) + { + dllPath = path; + break; + } + + if (dllPath == null) throw new WrapperException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'"); _dllHandle = LoadLibrary(dllPath);