mirror of
https://github.com/soukoku/ntwain.git
synced 2025-12-21 19:29:44 +08:00
Check for empty path in TryLoadCustomDSM.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--change these in each release-->
|
||||
<VersionPrefix>4.0.0.0</VersionPrefix>
|
||||
<VersionSuffix>alpha.8</VersionSuffix>
|
||||
<VersionSuffix>alpha.9</VersionSuffix>
|
||||
|
||||
<!--keep it the same until major # changes-->
|
||||
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
||||
|
||||
@@ -24,13 +24,25 @@ namespace NTwain.DSM
|
||||
{
|
||||
if (__dllPtr == IntPtr.Zero)
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
var curFile = Assembly.GetExecutingAssembly().Location;
|
||||
|
||||
if (string.IsNullOrEmpty(curFile))
|
||||
{
|
||||
using var proc = Process.GetCurrentProcess();
|
||||
curFile = proc.MainModule.FileName;
|
||||
}
|
||||
var folder = Path.GetDirectoryName(curFile);
|
||||
#else
|
||||
var folder = AppContext.BaseDirectory;
|
||||
#endif
|
||||
if (!string.IsNullOrEmpty(folder))
|
||||
{
|
||||
var dll = Path.Combine(
|
||||
Path.GetDirectoryName(curFile)!,
|
||||
folder,
|
||||
$@"runtimes\win-{(TWPlatform.Is32bit ? "x86" : "x64")}\native\TWAINDSM.dll");
|
||||
|
||||
__dllPtr = LoadLibraryW(dll);
|
||||
}
|
||||
|
||||
if (__dllPtr != IntPtr.Zero)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user