I am currently working on a project coded in C#, but I am desperately missing ROOT for some of the numerical work that needs to be done. In particular, I would like to use Minuit (or one of the other minimizers) for function fitting.
Has anyone of you ever used ROOT classes from C#? I assume that some kind of wrapper will be necessary, but I have no idea how exactly this would work.
I wonder if ROOTNET is still maintained. I tried using it but it is not compatible with my project.
I keep getting “BadImageFormatException: An attempt was made to load a program with an incorrect format”. I would appreciate if someone can point me in the right direction.
That said, I’ve not maintained it since ROOT version 5. The type system, at the ROOT level, is similar in ROOT v6 and v5, so it may well work without too much effort. However, as ROOT uses templates more and more heavily, understanding how to translate those to C# is going to become more and more important.
The particular error you are getting reminds me of a x32 vs x64 image error. The .NET runtime may have loaded a x64 bit version of itself and you then try to load a x32 bit version of the ROOT libraries. You can tell the builder to only build 32 bit versions of your .NET code, and that may solve the issue.
Unfortunately, this is a sideeffect of loading the root libraries in-process.