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