This looks really cool! Thanks for making it.
I actually just finished developing an interface between Julia and .NET for an internal project based on information from @oheil .
When I started that, I was a newcomer to both Julia and C#/VB.net so it seemed infeasible with the C interface.
So I did it using communications over pipes, like a client-server communication.
Though this takes time, (de-)serialization seems to be fine (i.e negligible to the user) in most cases, even with relatively large arrays (about tens of thousands of double precision numbers).
I do not know if you tackled this issue already but the main missing part for me in the documentation about julia’s C interface was how to use it properly to load and interact with modules and how to handle special types. I was completely lost i the whole packing / unpacking of pointers to structures…
Also, there are some base types that exist in Julia that do not in .NET, so some conversions need to be done explicitely. For instance I discovered that my .NET (maybe it is a matter of version) did not support
Keep up the work ! Cheers !
EDIT : See this answer from @Shuhua maybe its worth converging on this Correct process to use julia code from C# or VB .NET - #17 by Shuhua
I found almost no documentation, I just straight up read the Julia source code instead lol.
Regarding primitive types that are not cannot be converted, I personally have not run into any issues but I can have it promote them into larger containers if need be (Int8 → Int32 etc) but I havent had any issues so far.
I have just released the .NET 5.0 version of the project
Thanks for the link to the other thread, Ill see if at @Shuhua is willing to work together as I see he has done some work on natively converting C# arrays to Julia etc
Btw, Thoughts on implementing an abstract method interface for functions like what RuntimeMethod has and stuff? Can make it seem like a normal “method” object
Ok I think I made it multiplatform now. I have no way to test it on linux though.
Change → SetDllDirectory to Environment.CurrentDirectory
Change → “where.exe” → Windows ? “where.exe” : “which”
Does this look like it would work?
I will try it tonight.
which seems like the right command to me.
Once GitHub - JuliaLang/juliaup: Julia installer and version multiplexer becomes more widely deployed you can just execute
juliaup api getconfig1 and get back a JSON with information about installed Julia versions. At the moment this only works on Windows and if the user installed Julia from the Windows store, but I am very, very close to releasing the Mac and Linux version of this as well. The VS Code extension already tries this method to find the Julia binary, and then falls back to other ways if that doesn’t work.
So, this is more a FYI, maybe not entirely ready yet to be used, but should be much more ready in a few weeks.
Sorry but I am not that familiar with .NET at the moment !
Take a look at the DotNET.jl.
It provides a more friendly call syntax.
julia> T"System.String".new('6',Int32(3)) "666" julia> List=T"System.Collections.Generic.List`1" System.Collections.Generic.List`1[T] julia> List.new[T"System.Int64"]() System.Collections.Generic.List`1[System.Int64]("System.Collections.Generic.List`1[System.Int64]")
Thanks, will do!
I will try to implement something like
@CSusing System strT = T"String" my_str = strT("Test") str_len = my_str.Length
For the using implementation, probaly have it store them all in a list for each “using JuliaInterface” context? Is it possible to create a variable when a module is “used”?
Then read the list in reverse order so last added using statement is checked first?
Here is the current Julia.NET .NET → Julia Interface:
@netusing Test @netusing System val1 = T"ReflectionTestClass".TestStateField #< Requires  to actually get the field. If you dont put  or () then it will just return the FieldInfo object val2= T"ReflectionTestClass".StaticMethod() #To call a method. If you dont put  or () then it will just return the MethodInfo object val3 = T"ReflectionTestClass".StaticGenericMethod[T"Int64"]() "To call a generic method, put the generic types in  item = T"ReflectionTestClass"".new(3) #To call a constructor. If you dont put  or () then it will just return the ConstructorInfo object val4 = item.InstanceMethod(); #To call a instance method val5 = item.g #To Access a instance field myGenericItem = T"ReflectionGenericTestClass`1".new[T"Int64"](3) #To Create a generic instance of an object, put the generic types in . boxed5 = sharpbox(5) #Will return the sharp object of the long value "5" shouldBe5 = shapunbox(boxed5) #Will unbox the sharp object and return to native julia value myClass = T"Test.ReflectionTestClass" #<= Perform Assembly Search and Return the Sharp Type myClass2 = P"Test.ReflectionTestClass" #<= Perform one time assembly search and store the sharp type in a internal array (Reccommended for fast lookups) myClass3 = G"Test.ReflectionTestClass" #Get from internal array myClass4 = R"Test.ReflectionTestClass" #Remove from internal array handle = pin(sharpbox(5)) #Pin the Sharp object in the Sharp GC free(handle) #Will also auto free. You can also treat it like stream and put it in do end block
I tried it on OSX. It seemed to throw in this function.
Glanced at the source and it seems like your approach for Linux should work in any POSIX-like systems .net supports (OSX, FreeBSD: OSPlatform.OSX Property (System.Runtime.InteropServices) | Microsoft Learn)
Recently we have developed GUI using Avalonia C# + Julia
waiting for your suggestion & Support
GitHub link: https://github.com/PiResearchTech/Ayudha
Recently works well in Windows & Ubuntu
Hello ! I’ve been (somewhat lazily) following your work on JULIA.Net and I see you have been pushing v2.0.0 recently.
I was wondering if you intend to publish a NuGet package or some other packaged version of this library, or is it designed to remain in this form ?
Currently it seems your effort is the most advanced one (that I know of) and that would probably be of help to a lot of potential users. See What don't you like about Julia for "serious work"? - #2 by Oscar_Smith for instance !
Maybe in the future I will make a nuget package. For now this project is a result of me working on another commerical project.
I moved Julia.NET to JuliadotNET to support it being a julia package.
I made a lot of changes to it recently. It was quite the effort trying to launch .NET from Julia lol.
But it seems to work! So you can now launch c# from julia and julia from c#. The julia->c# still needs a lot of work but it works in my tests
One thing I noticed is that you cant launch .NET from Julia if your in REPL for whatever reason. (Any thoughts on why this may be and how to fix it?)
I will be posting the package to the julia repo in the coming weeks
Have a look at DotNET.jl, I think it is possible to launch .NET but it needs to be .NET version 6.0 or greater. The .NET Framework is a different animal and doesn’t work, if I remember correctly.
Btw, your project looks amazing! I’ve also created something similar with struct mapping so you can use your Julia structs in C#. I’ll have a closer look and compare notes with you when I have some time.
I have been spending some time designing my own fork of julia from scratch (for fun!.. I think…). If I ever get it to work I could theoretically allow you to add a custom JIT compiler. I could add a CLR JIT Compiler with this directly allowing to inline julia into .NET.
If I did so there would not need to be a library for interop. You would just native julia to control native c# and vs versa
Quick update on my julia runtime in .net project.
Made some pretty good progress! Very far from a working (able to actually run julia code) though. It is quite a massive project that will take a while. I have load out a plan in the Readme of the project. Take a look if your curious and/or interested in helping out! This will take a team effort to complete but I think will be worth it. I call it Julia++ as it would be more a fork of Julia since its not official at all.