diff --git a/src/CIL/common/directml/adapter_enumeration.cpp b/src/CIL/common/directml/adapter_enumeration.cpp index b7ead711..8391d23d 100644 --- a/src/CIL/common/directml/adapter_enumeration.cpp +++ b/src/CIL/common/directml/adapter_enumeration.cpp @@ -102,9 +102,12 @@ std::vector EnumerateDirectMLAdapters( const std::string& directml_directory) { LibraryPathHandle path_handle; - if (!directml_directory.empty()) { + // Only add to DLL search path if directory is not empty and contains actual DLL files + // Skip for current directory "." as it may interfere with system DLL loading + if (!directml_directory.empty() && + fs::exists(fs::path(directml_directory) / "DirectML.dll")) { path_handle = AddLibraryPath(directml_directory); - if (!path_handle.IsValid()) return {}; + // Don't fail if AddLibraryPath returns invalid handle, just proceed without it }; ScopeExit library_path_cleanup([path_handle]() { @@ -239,9 +242,12 @@ std::vector EnumerateDXCoreAdapters( const std::string& dxcore_directory) { LibraryPathHandle path_handle; - if (!dxcore_directory.empty()) { + // Only add to DLL search path if directory is not empty and contains actual DLL files + // Skip for current directory "." as it may interfere with system DLL loading + if (!dxcore_directory.empty() && + fs::exists(fs::path(dxcore_directory) / "DXCore.dll")) { path_handle = AddLibraryPath(dxcore_directory); - if (!path_handle.IsValid()) return {}; + // Don't fail if AddLibraryPath returns invalid handle, just proceed without it }; ScopeExit library_path_cleanup([path_handle]() { @@ -367,4 +373,4 @@ const DeviceEnumeration::DeviceList& DeviceEnumeration::EnumerateDevices( } // namespace common } // namespace cil -#endif \ No newline at end of file +#endif