[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


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++
>I think that I can do this by creating a C library that hosts the Mono
>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
>using reflection coupled with attributes to mark the routines I want to
>My questions are
>    - Is there an open source project out there that does this already?
>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
>managed code?
>Thanks in advance for your time.
>Mono-devel-list mailing list
>Mono-devel-list at lists.ximian.com

More information about the Mono-devel-list mailing list