[Mono-dev] Automatically generating a C wrapper library for a .NET assembly

Tom Philpot tom.philpot at logos.com
Mon Dec 6 16:30:50 EST 2010


Alan,

We do something similar to this in our Mac application. We wrote a custom
attribute which decorates the C# classes that we need to access from
Objective-C. Then we wrote a program which reflects over our compiled .NET
assemblies looking for our attribute then generates Objective-C wrappers
for our classes.

Unfortunately for you, our code is not open source, and since it's
targeted to Obj-C, it's probably not all that useful anyway. But I did
want you to know that it can be done, and it works rather well.

On 12/4/10 12:00 AM, "Alan Broun" <abroun at alanbroun.net> wrote:

>Hi there,
>
>I have a need (or think I do) to call .NET code from a native C/C++
>application. 
>
>I think that I can do this by creating a C library that hosts the Mono
>runtime,
>loads up the desired assembly and wraps the routines I want to call.
>
>Ideally though I'd like to be able to generate this C library
>automatically
>using reflection coupled with attributes to mark the routines I want to
>export.
>
>My questions are
>
>    - Is there an open source project out there that does this already?
>I've
>done some Googling but can't seem to find anything.
>    - If there isn't any open source code out there is that because it's a
>rubbish approach? Can anyone think of any problems with the way I want to
>call
>managed code?
>
>Thanks in advance for your time.
>
>Regards
>
>Alan
>
>_______________________________________________
>Mono-devel-list mailing list
>Mono-devel-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list