When running my application on a Windows machine that does not have the Hana Client installed, I get the DirectoryNotFoundException found above. This occurs in both the Ado.Net provider for .Net 4.5 and the .Net core 2.1 provider.
In HanaUnmanagedDll.SearchNativeDlls, the first place the code looks for libadonetHDB.dll is in Directory.GetCurrentDirectory(). In a VSTO Excel Add-In this returns the path to the My Documents folder. In a .Net Core Windows Service, this returns c:\windows\system32.
Bug #1: After checking the current directory, the code then searches a number of directories based off the Assembly.GetEntryAssembly().Location. In a VSTO Excel Add-In, there is no entry assembly so Assembly.GetEntryAssembly() returns null and then we get a NullReferenceException when trying to get the Location.
Bug #2: The code then checks the executing assembly's location with this:
new FileInfo(new Uri(Assembly.GetEntryAssembly().CodeBase).AbsolutePath).Directory.FullName
In my WPF Windows application, this returns my application folder "c:\Program%20Files\FastClose\WindowsClient". When the code later on tries to get the subdirectories of this folder by calling Directory.GetDirectories, a DirectoryNotFoundException is thrown because of the "%20".
My workaround is to set the current directory myself at application startup, this works for both .Net Core, Full Framework and VSTO Excel add-ins:
var executionFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Directory.SetCurrentDirectory(executionFolder);