Updated 2016-01-18 05:03:54 by mistachkin

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…

JJM: Also see Garuda.
On Jan 31, 9:09 pm, mike.hoege...@gmail.com 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:

 % package require tcom
 % set myCom [tcom::ref createobject "ClassLibrary1.Class1"]
 % $myCom Double 6

Hope this helps