Using ROOT classes from C#

Dear all,

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.

Thanks for any hint you can give,

Sven

Hi Sven,

See Gordon Watt’s nice binding to C#:

rootdotnet.codeplex.com/

and

linqtoroot.codeplex.com/

which has some pretty impressive features.

Cheers,
Philippe.

Hello,

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.

Cheers,
Andrew

I see this page http://rootdotnet.sourceforge.net
I am not sure it means it is maintained.
May be the author, @gwatts can tell.

Reply from @gwatts (or @Gordon_Watts):

Hi,
ROOT.NET was moved to github sometime ago: GitHub - gordonwatts/ROOT.NET: Build .NET wrappers for the ROOT scientific data analysis toolkit

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.

Cheers,
Gordon.