Interoperability with .NET

dotnet
interoperability

#1

We have some Dimension Selector built in .NET which i want to invoke from Julia. IS there any Julia to .NET interoperability tools?

I have used R.NET for R to .NET connection and Pythonnet for Python to .NET connection. So looking to see if anything similar is available for Julia to .NET.


#2

Not that I’m aware of. I agree, it would be super cool if there was a package that provided interop with .Net, there is a lot of cool software out there on that platform!

And with .Net Core it should be quite simple to a) make that work on all platforms, not just Windows, and b) completely self-host .Net, i.e. have a private installation in the interop package, no dependency on anything systemwide etc.

PS: This probably doesn’t belong in this discourse section, it seems entirely unrelated to VS Code. Maybe one of the mods can move the thread?


#3

Moved to Usage.


#4

Yes, such a package for .NET interop would be great.
For a optimization project with some complex GUI I am currently working on a C# application calling julia like this:

    class Julia
    {
        [DllImport("kernel32.dll")]
        public static extern bool SetDllDirectory(string pathName);

        [DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern void jl_init(string julia_home_dir);

        [DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern IntPtr jl_eval_string(string str);

        //[DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)]
        //public static extern IntPtr jl_box_float64(float value);

        //[DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)]
        //public static extern double jl_unbox_float64(IntPtr value);

        [DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern void jl_atexit_hook(int a);

        //[DllImport("libjulia.dll", CallingConvention = CallingConvention.Cdecl)]
        //public static extern IntPtr jl_array_data(IntPtr value);

        public static void julia()
        {
            SetDllDirectory(@"c:\Program Files\Julia-0.6.2\bin\");

            jl_init(@"c:\Program Files\Julia-0.6.2\bin\");

            jl_eval_string("[\"2\" \"3\" \"4\"]");
            jl_eval_string("write(\"test.out\",\"helloxx2\");");
            jl_eval_string("println(\"test.out\"*\"hello2\");");

            jl_atexit_hook(0);
        }
    }

Still experimenting with it, with not so much success.