I am currently working on a projet involving julia as a base language for mathematical computations, and .NET (C# or VB) for the GUI part.
I want to emphasize the fact that I am quite new to dll handling, julia and .NET (not general programming though) so sorry in advance if I same dumb things.
I developed a julia package for my project where everything works fine. Now I am facing the part where I need to call this julia code from .NET.
With the information provided in the documentation regarding julia code embedding in C/C++ and this thread Embedding Julia in Csharp or VB.net, I managed to get a working code calling the libjulia.dll
and parse sqrt(2)
in a .NET application.
Of course, my actual code is much more complex than this and I am stuck at this point in terms of strategy.
The aforementioned examples call (and do AFAICT):
-
jl_init()
to spawn a julia process -
jl_eval_string(<julia expression>)
to parse a julianic expression -
jl_atextit_hook(<error code>)
to clean up the julia process and close it.
This process, from the viewpoint of .NET seems to start julia, execute one expression and close.
My concern here is that in my project, I will have to:
- Define some parameters in .NET
- Call a julia function with these parameters as arguments
- Plot or use the outputs of the julia function in .NET
- Reuse these results in other julia functions a bunch of times
- Close julia when the .NET application is closed.
What I can’t figure at the moment is :
- I will need to be able to use and reuse results of julia functions in both julia and .NET, is that a problem or will it lead to problems
- I would like to avoid restarting julia at every function call
- Do I have to call
jl
files fromjl_eval_string
or should I make my julia code a dll and if so how ? I’ve seen PackageCompiler.jl, but I don’t see how it could help here.
Thanks for the help !