Calling .NET Framework from Julia

Hi,

I’m looking for a way to call and use .NET Framework (4.7) dlls from Julia, unfortunately the only options I’ve found for using .NET only cover the non-framework versions of .NET.

Unfortunately the libraries I need to use are 3rd party and cannot be converted to .NET 5+.

GitHub - azurefx/DotNET.jl: Julia ❤️ .NET currently does not support the .NET Framework so is not an option.

GitHub - HyperSphereStudio/JdotNET: Julia-.NET Interface Library. Provides Interop between the .NET ecosystem and the Julia programming language if I understand correctly only support calling Julia from .NET and not the other way around

Has anyone looked into this before and could suggest some alternatives?

Some of the options I’m considering is either calling them through python and pythonnet, or to create a .NET service which would run all the time and allow me to do web requests and transfer data that way. I don’t really like either of those solutions so just looking if someone has any better suggestions.

As much as I didn’t want to use python for this - it seems to work well and is simple enough to implement.

Below example works for me and allows to use .NET Framework dlls in Julia:

using PyCall

(dll_folder, dll_file) = splitdir(raw"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Collections.dll")

py"""
import sys
sys.path.append($dll_folder)
"""

clr = pyimport_conda("clr", "pythonnet")
clr.AddReference(splitext(dll_file)[1]);

Collections = pyimport("System.Collections");

myQ = Collections.Queue()
myQ.Enqueue("Hello");
myQ.Enqueue("World");
myQ.Enqueue("!");

while myQ.Count > 0
    println(myQ.Dequeue())
end

Output:

Hello
World
!