Using panama with C# dll

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Jun 19 09:47:54 UTC 2023


I am not an expert on this topic (and I'd ask others to chime in and/or 
validate the stuff below), but I'd assume that options to call into a C# 
assembly are a bit limited (since a #NET assembly doesn't use classic C 
ABI):

* use a compiler that understands #NET (obviously great if you work in 
visual studio)
* use COM (I have seen examples in this sense on this mailing list)
* use some 3rd party solution which allows to "export" symbols from C# [1]
* try to find a way to embed a #NET runtime in your Java application [2]

I believe the dlls in the project you refer to are plain #NET 
assemblies, so I don't think a regular (e.g. non-MSVC) compiler would be 
able to do much with them - and that conclusion would extend to the 
Linker API.

Of these approaches, the last seem promising, as your Panama application 
would interact not with the assembly directlty, but with a library that 
implements the #NET functionalities (think of it as some kind of JNI for 
#NET). From there, you have ways to obtain references to #NET methods, 
and call them [3].

Of course, I have not tried any of this :-)

[1] - https://github.com/3F/DllExport
[2] - https://www.mono-project.com/docs/advanced/embedding/
[3] - 
https://www.mono-project.com/docs/advanced/embedding/#invoking-methods-in-the-cil-universe


On 17/06/2023 13:24, Christoph Läubrich wrote:
> I'm wondering if anyone has already used panama with a c# DLL[2]?
>
> I especially came across this example [1] that says
>
> > The assemblies can be used to read RAW files on Windows, Linux,
> > and MacOS using C# or other languages that can acces a .Net assembly
>
>
> So I'm wondering if similar is possible using panama/java as well?
>
>
> [1] https://github.com/thermofisherlsms/RawFileReader
> [2] 
> https://github.com/thermofisherlsms/RawFileReader/tree/main/libs/NetStandard20


More information about the panama-dev mailing list