Is it possible for a starpack-wrapped Tcl/Tk application to use external
.NET assemblies using Garuda? I use the latest build (1.0.7900.33333,
2021-08-23).
My Tcl/Tk application is wrapped into a starpack with ActiveState
TclApp. I wanted to check if Garuda can work with my app.
Ideally, I want to embed Eagle.dll and Garuda.dll into my starpack but
at first, I just installed Eagle/Garuda binaries to the lib folder under
the working directory and inserted the path to the head of ::auto_path.
The purpose to use Garuda is to load an external managed assembly from
the local sub-folder. The assembly is dependent on several DLLs in the
same folder. I keep them out of my starpack.
+ lib\
+ Garuda-1.0\
+ dotnet.tcl
+ Eagle.dll
+ Garuda.dll
+ helper.tcl
+ pkgIndex.tcl
+ RemoteClient\
+ Google.Protobuf.dll
+ Grpc.Core.Api.dll
+ Grpc.Core.dll
+ grcp_csharp_ext.x86.dll
+ GRPCRemoteClient.dll (This is the DLL to be loaded from MyApp.tcl)
+ System.Buffers.dll
+ System.Memory.dll
+ System.Numerics.Vectors.dll
+ System.Runtime.CompilerServices.Unsafe.dll
+ MyApp.tcl
MyApp.tcl is the main script. It loads Garuda.
The eagle command loads RemoteClient\GRPCRemoteClient.dll and the
classes and the methods are used.
If MyApp.tcl is not wrapped into a starkit, it works well.
However, if it is wrapped, it can't create any instance of classes
defined inside GRPCRemoteClient.dll, although it seemed to load
GRPCRemoteClient.dll successfully.
I followed the instruction in this article and added
METHOD_PROTOCOL_V1R2 flag before loading Garuda package.
https://wiki.tcl-lang.org/page/Garuda.
# MyApp.tcl
set exehome [pwd]
set auto_path [linsert $auto_path 0 [file join $::exehome lib]]
namespace eval ::Garuda {
variable methodFlags 0x40; # METHOD_PROTOCOL_V1R2
}
package require Garuda
eagle {
set dll_dir "./GRPCRemoteClient"
set dll_file "GRPCRemoteClient.dll"
set dll_path [file join $dll_dir $dll_file]
object invoke System.Reflection.Assembly LoadFrom $dll_path
}
# => {GRPCRemoteClient, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null} c199bf34-6a72-4256-8e1c-5857959232ad 293
# => Seemed successful.
eagle {
object create -alias GRPCRemote.GRPCRemoteClient "127.0.0.1" 50051
}
# => {type "GRPCRemote.GRPCRemoteClient" not found} {expected type value
but got "GRPCRemote.GRPCRemoteClient"}
# => Failed.
Yusuke Yamasaki <
tm92...@gmail.com>