HDF.PInvoke
HDF.PInvoke copied to clipboard
Invalid dll-path when there is a '#' in the path
In NativeDependencies.GetAssemblyName()
the binary search path based on this code:
string myPath = new Uri(System.Reflection.Assembly
.GetExecutingAssembly().CodeBase).AbsolutePath;
myPath = Uri.UnescapeDataString(myPath);
return myPath;
which transforms a path c:\Dir\Sub#Dir\HDF.PInvoke.dll
into c:\Dir\Sub
.
A fix could look like this:
var myPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
return Path.GetDirectoryName( myPath );
which transforms a path c:\Dir\Sub#Dir\HDF.PInvoke.dll
into c:\Dir\Sub#Dir
.
I would say this is a this is a bug in Assembly.CodeBase
, because '#' should be escaped as '%23'.
or new Uri(...Assembly.EscapedCodeBase).AbsolutePath
would do the job too.
Replacing Uri.AbsolutePath
& Uri.UnescapeDataString()
with Uri.LocalPath
might also be an option?