Correct process to use julia code from C# or VB .NET

Regarding c# - (De)serialization of BSON data of potentially nested objects with specific structure - Stack Overflow did you want to pass a complicated structure between Julia and C#? If that is the case, I am afraid the paradigm may not be an ideal one. My personal feeling is that the ZeroMQ and MsgPack (or JSON etc.) mechanism is suitable if

  • Julia mainly does scientific computing;
  • The interaction between Julia and C# is infrequent
  • The data communicated are mainly arrays (1d or Nd) rather than complicated custom structures (like a full-fledged class in C#); otherwise, it is difficult to implement the pack/unpack operations in two different languages.

I just started working on a small project in which C# implements the UI (in WPF) and Julia provides the computing core (mainly optimization with JuMP). Your sharing helps a lot.

1 Like

Do you know this thread: Interoperability with .NET ?

It looks cool. Could you please explain the main idea under the interoperation between Julia and C#? It seems that the workhorse is jl_eval_string, but how can I pass an array to it (which may be built by the C# part via interaction with the user)?

Besides, I heard that eval in Julia is of low efficiency. Does it matter here?

Yes, actually, I started everything by reading what you did (you project doTimetable is cite above), though I did not see anything about pointers and other complex stuff…

@Shuhua In my current code, I duplicate all the custom structure definitions between the two implementations, and I create a custom JsonConverter that acts recusrively.
I will try to refactor a bit and post it here, or maybe create a github repo, I have to see…

I’ve been thinking of attempting this kind of thing for a while also (C# for front-end GUI and graphics and Julia for a back-end “computation and analytical engine”) but I’m really just starting out and nowhere close to where you have already gotten and/or oheil got with his doTimeTable application. There’s just not a lot out there on this so I applaud both of your persistence!

Just throwing this out there and not knowing too much about it myself yet, but what about leveraging the Arrow binary format to pass data back and forth? I believe the idea is it was designed exactly for this kind of passing binary data around and be an independent, language-agnostic format whereby binary Arrow data created in language A should “just work” to be read in by language B. It even looks to support streaming.

Although it looks like not every language fully supports all defined features yet according to this status page, Julia and C# do both appear to already support many of the most basic data types as well as Arrow file and stream formats.


Yep, that’s pretty much my conclusions too, there is nothing much out there about C# and julia. Thanks for the applause !

I personally checked Arrow myself, but currently neither the C# nor the Julia implementations support tensors so no vector or no matrix storage, which was my main concern.
I also tested MsgPack that worked fine until ND-arrays / tensors were involved.
The BSON was also a bummer at first but at least I found sources to develop my own C# formatter/resolver.

The overall message is JSON/BSON is very generic but only defines the grammar, understand only separators and basic syntax, but the specification does not consider specific objects such as tensors in a unified manner between implementations.
On the other side, Arrow or MsgPack degine very specific objects, but just do not currently support ND arrays as far as I can tell.

Is there some workaround possible for tensors/matrix, at least vectors with e.g. “List” that Julia and C# support (note “Large List” and “Fixed Size Binary” not supported by Julia, but not C#)?

At Implementation Status — Apache Arrow v9.0.0

I see Julia is the only language with full data type support for Arrow, even with one more than C++ (and @quinnj should be proud of making Julia (official) Arrow work). But (Sparse) Tensor, that neither language support is in another section “IPC Format” (where Julia still has next best support after C++, and C# least). I do see “the Python, R, Ruby and C/GLib libraries follow the C++ Arrow library.” Does that mean e.g. tensors too (for e.g. Python)? [Then for other sections after that one, Julia support drops off, I suppose all those also apply to e.g. Python.]

Often Julia prefers Julia-only code, and there was maybe a good reason for Arrow.jl. I suppose the C++ Arrow library could have been wrapper in Julia (and C#?), and still could, for as good support as for C++ and Python. Curious why wasn’t done.

I’m not sure if there’s anything to learn from e.g. this package with “The aim is to serialize only the numeric weights”, i.e. a vector, using Arrow.jl:

Hi, @BambOoxX and @tdierickx.

As inspired by the Interoperability with .NET, I have made some attempt to embed Julia inside a C# (or .NET in general) program. Though the raw C API is a little verbose, it seems feasible. I have prepared a series of brief tutorials for a beginner and for my own reference. Please check JuliaCSharp/Embedding at main · ShuhuaGao/JuliaCSharp · GitHub. Hope it helps. Any feedback is welcome. :grinning:

The plan next is to craft a .NET library that provides some wrapper classes to hide all these C API details. I have found a preliminary attempt here: GitHub - WangyuHello/JuliaSharp: C# Interop for Julia , which may serve as an initial reference.


Awesome! I’m looking forward to taking a closer look at these!

Interesting thread, I was just thinking about this. Especially since Microsoft is taking C# UIs cross-platform with MAUI. Also not a big fan of Julia-native UI solutions available right now. I’d like to replace a MATLAB-created GUI.

Hi @Shuhua

Perhaps we could merge some of our work together?

Here is my interop library: Interoperability with .NET - #21 by HyperSphereStudio

It provides interop from C# to Julia and Julia to C# (Julia → C# is far more primitive atm though).

I see you have some C interface backend, I have been working on the frontend as well if you want to take a look. Mind if I use some of your work for my JLArray etc?

1 Like

Hi, @HyperSphereStudio. Excellent work!

Please feel free to take the code in my repo. Regarding JLArray, maybe it is better to map a Julia array to array or from the opposite side to leverage the matrix functions therein.

I would like to provide help, but currently I am working on a paper. I will join your efforts ASAP.

ps. Would you please enable the discussion panel in your repo? Previously I got some difficulty in automatic memory handling and would like to learn from you.


Hi, based on ur suggestion we took a first step like this way :slight_smile:


GitHub link : GitHub - PiResearchTech/Ayudha: Avalonia + Julia interface for cross platform Windows GUI


Obviously, there seems to be a growing requirement to have julia integrate with .NET !

1 Like

That is my main use case too !

1 Like

@Shuhua @HyperSphereStudio @oheil @BioTurboNick Quick poll, do you think it could be useful to ask for a repo in so that such .NET / Julia interfaces gain more attention ?

1 Like

Of course.
But I didn’t used the .NET interface package yet, so can’t say anything about its quality compared to the other Interop packages…

Hmm, regardless of the current state of development, it could be relevant to set it there so that potential contributors can share their efforts, don’t you think ?


This sounds good to me if others are also onboard with it.

1 Like

I’m facing the exact same problem like you BambOoxX… What is the progress of all you guys hard work :slight_smile:

This is the only thread I have found regarding Julia/C# :frowning: So much help else…