diff --git a/src/01/KSociety.SharpCubeProgrammer/CubeProgrammerApi.cs b/src/01/KSociety.SharpCubeProgrammer/CubeProgrammerApi.cs index b33e524..c52dabf 100644 --- a/src/01/KSociety.SharpCubeProgrammer/CubeProgrammerApi.cs +++ b/src/01/KSociety.SharpCubeProgrammer/CubeProgrammerApi.cs @@ -57,11 +57,13 @@ public CubeProgrammerApi(IWmiManager wmiManager, ILogger? log if (Environment.Is64BitProcess) { - Assembly.LoadFrom(@".\dll\x64\STLinkUSBDriver.dll"); + //Assembly.Load(@".\dll\x64\STLinkUSBDriver.dll"); + Native.ProgrammerApi.LoadLibraryEx(@".\dll\x64\STLinkUSBDriver.dll", IntPtr.Zero, 0); } else { - Assembly.LoadFrom(@".\dll\x86\STLinkUSBDriver.dll"); + Native.ProgrammerApi.LoadLibraryEx(@".\dll\x86\STLinkUSBDriver.dll", IntPtr.Zero, 0); + //Assembly.LoadFrom(@".\dll\x86\STLinkUSBDriver.dll"); } } catch (Exception ex) diff --git a/src/01/KSociety.SharpCubeProgrammer/KSociety.SharpCubeProgrammer.csproj b/src/01/KSociety.SharpCubeProgrammer/KSociety.SharpCubeProgrammer.csproj index 194e280..4aea0bd 100644 --- a/src/01/KSociety.SharpCubeProgrammer/KSociety.SharpCubeProgrammer.csproj +++ b/src/01/KSociety.SharpCubeProgrammer/KSociety.SharpCubeProgrammer.csproj @@ -24,10 +24,10 @@ --> - + - + diff --git a/src/01/KSociety.SharpCubeProgrammer/Native/ProgrammerApi.cs b/src/01/KSociety.SharpCubeProgrammer/Native/ProgrammerApi.cs index a495482..5ab02f1 100644 --- a/src/01/KSociety.SharpCubeProgrammer/Native/ProgrammerApi.cs +++ b/src/01/KSociety.SharpCubeProgrammer/Native/ProgrammerApi.cs @@ -12,6 +12,9 @@ internal static class ProgrammerApi private const string ProgrammerDll32 = @".\dll\x86\Programmer.dll"; private const string ProgrammerDll64 = @".\dll\x64\Programmer.dll"; + [DllImport("kernel32.dll", CharSet = CharSet.Auto, EntryPoint = "LoadLibraryEx")] + internal static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags); + #region [STLINK] #region [GetStLinkList] diff --git a/src/01/Samples/Programming/Programming.csproj b/src/01/Samples/Programming/Programming.csproj index d28204b..13d915c 100644 --- a/src/01/Samples/Programming/Programming.csproj +++ b/src/01/Samples/Programming/Programming.csproj @@ -7,7 +7,7 @@ - +