www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C# to D calling

reply BCS <ao pathlink.com> writes:
Has anyone gotten c# code to call D code? Loading a D dll with a c api is 
good enough. Going the other way might also be of interest to me.
May 18 2007
parent Daniel Keep <daniel.keep.lists gmail.com> writes:
BCS wrote:
 Has anyone gotten c# code to call D code? Loading a D dll with a c api
 is good enough. Going the other way might also be of interest to me.

Sadly, I'm not sure if I even have cs installed anymore... D kinda got in the way :P Calling D code from C#, I imagine, would be the same as trying to call a D DLL from any other language that can do C functions; just make sure you init the GC, module ctors, etc. Going the opposite way, you have two options AFAIK: one is to expose the C# class using COM and then using IUnknown from D. The other is to actually embed the .NET runtime into your app, but I'm not sure exactly what you can do with that. Here's a short CodeProject article on the first (using C++, tho): http://www.codeproject.com/csharp/ManagedCOM.asp -- Daniel -- int getRandomNumber() { return 4; // chosen by fair dice roll. // guaranteed to be random. } http://xkcd.com/ v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
May 18 2007