[Mono-list] How to Call Mono-Librray Function from Native C Code

ivica_rogina ivica.rogina at hs-karlsruhe.de
Sat Sep 6 08:46:53 EDT 2008


After finding dozens of examples how to call native library function from
mono code, i have given up finding an example for how to call a function in
a mono library from a native C-program. I do see lots of API function in the
mono documentation, but I am not able to build an example out of these. Say,
I have written a program DotNetCode.cs like:

public class ExampleClass
{
   public static int ExampleFunction(int n) { return 2*n; }
}

and compiled it with

mcs -t:library DotNetCode.cs to get a file DotNetCode.dll.

What would a native C-Programm (for Linux or Solaris) look like that could
call the defined ExampleFunction?
Probably somethin like

#include <mono/...>
int main(int argc, char **argv)
{
  ...
  ExampleFunction = mono....(...);
  ...
  printf("%d\n",ExampleFunction(2));
}

There should be a tiny example for this somewhere. Maybe there is, but I
don't know the terminology to search for.

Could anybody help me, please?

-- 
View this message in context: http://www.nabble.com/How-to-Call-Mono-Librray-Function-from-Native-C-Code-tp19346311p19346311.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list