0

So I need to pass arguments to function (in C#) and then get the results. I need to do this from Python. I do same thing with C++ (using ctypes and 'extern "C"' and I have no problems with that). I found something here, but it needs some 'DllExport' and other libraries (NuGet?) in C# - I do not know how to get (or use - I tried copy/pasting but I got an error about those non-existing libraries) them (a beginner in C#). I am using Ubuntu 16.04 with Mono for C#. Would this be as simple as C++ extern thing? Should I compile the .cs into .dll? I compile to .exe with csc command and then mono cs.exe to run it.

To sum up - I need help with that (in link) first answer, because I think it would work best for me. Thank you in advance.

Ri Di
  • 163
  • 5
  • Why do you need to load it in-process? Write command-line C# application using your function and call it like any other command-line tool. – Alexey Rumyantsev Apr 08 '21 at 13:16
  • that would be simple, but I need to receive data from that function – Ri Di Apr 08 '21 at 13:33
  • So whats the problem? Just output your data to stdout and read it in python, or you can use it in pipelines like other linux tools do. – Alexey Rumyantsev Apr 08 '21 at 13:51
  • There are some [tools for exporting unmanaged functions](https://stackoverflow.com/questions/31156523/c-sharp-unmanaged-dll-exporting-how-it-works), But I have no idea if it works on newer .net versions or linux. Consider running it as a process and either parse the stdio output or use one of the many IPC mechanisms to talk to the process. – JonasH Apr 08 '21 at 14:47
  • I guess I could read the output. thanks. – Ri Di Apr 08 '21 at 16:03

0 Answers0