hdfgroup / hdf.pinvoke.1.10 Goto Github PK
View Code? Open in Web Editor NEWHDF.PInvoke for .NET Standard
License: Other
HDF.PInvoke for .NET Standard
License: Other
Hello,
I am trying to use this library to read and write data from HDF5 files. I am able to read data from a HDF5 file but when I try to save a HDF5 file I get this error:
Unhandled exception. System.TypeInitializationException: The type initializer for 'HDF.PInvoke.H5T' threw an exception.
---> System.TypeInitializationException: The type initializer for 'HDF.PInvoke.H5DLLImporter' threw an exception.
---> System.IO.FileNotFoundException: libhdf5.dylib
at HDF.PInvoke.H5MacDllImporter..ctor(String libName) in /home/appveyor/projects/hdf-pinvoke-1-10/src/HDF.PInvoke.1.10/H5DLLImporter.cs:line 213
at HDF.PInvoke.H5DLLImporter..cctor() in /home/appveyor/projects/hdf-pinvoke-1-10/src/HDF.PInvoke.1.10/H5DLLImporter.cs:line 70
--- End of inner exception stack trace ---
at HDF.PInvoke.H5T..cctor() in /home/appveyor/projects/hdf-pinvoke-1-10/submodules/HDF.PInvoke/HDF5/H5Tglobals.cs:line 38
--- End of inner exception stack trace ---
at HDF.PInvoke.H5T.get_NATIVE_INT32() in /home/appveyor/projects/hdf-pinvoke-1-10/submodules/HDF.PInvoke/HDF5/H5Tglobals.cs:line 332
at HNSW.Net.Demo.Hdf5Utils.GetDatatype(Type type) in /Users/siddjain/github/hnsw-sharp-demo/Hdf5Utils.cs:line 153
at HNSW.Net.Demo.Hdf5Utils.WriteDataset[T](Int64 fileId, String dataset, T[] data, UInt64[] dimensions) in /Users/siddjain/github/hnsw-sharp-demo/Hdf5Utils.cs:line 193
at HNSW.Net.Demo.Program.Main() in /Users/siddjain/github/hnsw-sharp-demo/Program.cs:line 87
Its strange because while reading from HDF5 file I don't get any System.IO.FileNotFoundException: libhdf5.dylib
exception.
The full code for the Hdf5Utils.cs class in the stacktrace can be seen here: https://github.com/siddhsql/hnsw-sharp-demo/blob/main/Hdf5Utils.cs
In addition I set DYLD_LIBRARY_PATH
equal to the location where the libhdf5.dylib
can be found. I am running on Mac os.
$ ls -al /opt/homebrew/lib/libhdf5.dylib
lrwxr-xr-x@ 1 siddjain admin 39 Jul 10 17:34 /opt/homebrew/lib/libhdf5.dylib -> ../Cellar/hdf5/1.14.1/lib/libhdf5.dylib
I am using below version of the library:
<PackageReference Include="HDF.PInvoke.1.10" Version="1.10.612" />
Below are actual screenshots if it helps:
Currently, the assembly is not signed with a strong name because during build, the following settings have no effect:
<!-- Sign assembly -->
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
<PublicSign>true</PublicSign>
<AssemblyOriginatorKeyFile>$(Root)submodules/HDF.PInvoke/HDF.PInvoke.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
Signing should be reenabled once it is clear how to accomplish this in a portable way.
We are looking to target a specific ARM64 platform(working to cross compile the native HDF libraries). Is there a recommended way to add support for another platform?
Seems like it should be strait forward by adding another architecture specific folder. Just wondering if there is anything else that might need to be changed besides adding the appropriate native libraries.
I am using HDF.PInvoke.1.10 with F# on OS X. However, H5F.create()
results in the following exception being thrown:
Unhandled exception. System.TypeInitializationException: The type initializer for 'HDF.PInvoke.H5T' threw an exception.
---> System.TypeInitializationException: The type initializer for 'HDF.PInvoke.H5DLLImporter' threw an exception.
---> System.IO.FileNotFoundException: hdf5
at HDF.PInvoke.H5MacDllImporter..ctor(String libName) in /home/appveyor/projects/hdf-pinvoke-1-10/src/HDF.PInvoke.1.10/H5DLLImporter.cs:line 169
at HDF.PInvoke.H5DLLImporter..cctor() in /home/appveyor/projects/hdf-pinvoke-1-10/src/HDF.PInvoke.1.10/H5DLLImporter.cs:line 42
--- End of inner exception stack trace ---
at HDF.PInvoke.H5T..cctor() in /home/appveyor/projects/hdf-pinvoke-1-10/submodules/HDF.PInvoke/HDF5/H5Tglobals.cs:line 38
--- End of inner exception stack trace ---
at [email protected](Int64 id, String name, String[] data) in /Users/davidmeijer/Dropbox/My Mac (Davids-Mac-mini.local)/Downloads/h5/Program.fs:line 11
at Program.run() in /Users/davidmeijer/Dropbox/My Mac (Davids-Mac-mini.local)/Downloads/h5/Program.fs:line 18
at <StartupCode$h5>.$Program.main@() in /Users/davidmeijer/Dropbox/My Mac (Davids-Mac-mini.local)/Downloads/h5/Program.fs:line 23
The following code sample in a F# project reproduces the previously shown error:
module Program
open HDF.PInvoke
type IHdf5ReaderWriter =
abstract WriteStrings: int64 * string * string [] -> unit
let Hdf5AttributeRW () =
{ new IHdf5ReaderWriter with
member _.WriteStrings (id : int64, name : string, data : string []) =
let dataType = H5T.create(H5T.class_t.STRING, H5T.VARIABLE)
()
}
let run () =
let fileId = H5F.create("./test_hdf5.h5", H5F.ACC_TRUNC)
let rw = Hdf5AttributeRW()
rw.WriteStrings(fileId, "version", [| "0.1.0" |])
H5F.close(fileId) |> ignore
0
[<EntryPoint>]
run() |> printfn "%A"
I managed to find a work-around by copying the binaries in /runtimes/osx-x64/native/
directly to the bin/Debug/net5.0
folder. I'm not sure, but I think the exception is caused by the H5MacDllImporter
not being able to properly find those files.
I was hoping somebody could shed some light on this issue for me. Thanks!
HI,
I'm able to iterate over the structure of h5 file but it does not iterate over each object attributes if there any.
Is it possible to do so (and print the attributes values, types, etc)?
Reason is currently unclear. See: https://travis-ci.org/Apollo3zehn/HDF.PInvoke.1.10/builds/543852155 .
Hi,
Is there a way to read generic h5 file structure like the hdfview Java app using pinvoke?
As soon as a Symbol is accessed (e.g. H5T.NATIVE_DOUBLE), the FileNotFoundError is thrown.
Reason:
returns the string <Unknown>
and so the file path is not built correctly.
No solution known yet. A workaround is to copy the native lib into the current directory.
More info: https://stackoverflow.com/questions/40477734/executing-assembly-location-is-unknown
@gheber, can you please add this project to the AppVeyor account for automatic builds?
Is there a way to register for the console output of errors and such? I would like to get all traces and outputs in my logging framework
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.