C# Interop

David Gileadi gileadis at NSPMgmail.com
Mon Jan 31 13:30:20 PST 2011


On 1/31/11 2:25 PM, Eelco Hoogendoorn wrote:
> Hi all,
>
> At work I currently develop in C++ with a C# front-end, using CLI interop.
>
> Ive been using D for quite a while for hobby projects, and needless to say, it
> makes C++ feel like masochism. Id like to convince my coworkers that adding D
> in the mix is more than just another complication.
>
> But im not quite sure what would be the best way to do C# and D interop. CLI
> will no longer do me any good I fear.
>
> Do I just create a D DLL with a bunch of free extern(C) function for
> communication? What about marshalling? Is using unsafe pointers back and forth
> the best I can do? C# can read from a pointer allocated by D in unsafe mode,
> and D can read from a pinned C# pointer, right?
>
> (no, im not looking for D.NET; what I miss in C# is to-the-metal /
> compilation.)

It's been a number of years and it was in D1, so take this for the 
little value it may have, but the last time I tried making a D DLL used 
by a C# client I got hangs.  I suspected it was the interaction of the 
garbage collectors but didn't have the time to debug it (it was for a 
school project).  I'd be interested to hear if someone else has gotten 
this working.

-Dave


More information about the Digitalmars-d mailing list