tomk: The following item appeared on comp.lang.tcl concerning how to call a C# function from some tcl code. It uses tcom to do the work…
On Jan 31, 9:09 pm, [email protected] wrote: > I find myself with the need to call into C# code (on windows) from a > tcl script. > much like you can call into C with C extensions. > It's ok if have to make some C/C++ glue to duct-tape it all together > does anybody have some advice on how i would go about doing this? > Or maybe a pointer at some code that already does this ? I'd try using tcom for this. Create a C# class library that implements the interface that you want, here is my sample one: using System; namespace ClassLibrary1 { public class Class1 { public Class1() {} public int Double (int val) { return val * 2 ; } } } Make sure that the project has register for COM Interop set to true and then build it. You should now be able to do the following: C:\Projects\ClassLibrary1\bin\Debug>tclsh % package require tcom 3.9 % set myCom [tcom::ref createobject "ClassLibrary1.Class1"] ::tcom::handle0x00923F98 % $myCom Double 6 12 % Hope this helps Jackson