Question Julian Matthews · Dec 31, 2025

Examples of using External Language Server for Dotnet

Hey everyone.

I have been taking a look at the External Language Server functionality to hook into some Dotnet functions, and I am hitting a bit of a wall.

Based on the example in the documentation here I can get the same result doing:

ENV>Set netGate = $System.external.getDotNetGateway()
ENV>Set netProxy=netGate.new("System.DateTime",0)
ENV>Write netProxy.Now,!
2025-12-31 14:37:58.6022705

However, if I then try another system class, I get an error:

ENV>Set netGate = $System.external.getDotNetGateway()
ENV>Set netProxy=netGate.new("System.Convert",0)
ENV>Write netProxy.ToBoolean(123)
<THROW>%Constructor+33^%Net.Remote.Object.1 *%Net.Remote.Exception <GATEWAY> InterSystems.Data.IRISClient.Gateway.GatewayException InterSystems.Data.IRISClient.Gateway.Gateway.dynamicFindConstructor(String className, Int32 parameterCount, Boolean isRecast) Constructor not found: System.Convert(1)

(don't judge the method choice, I know it's not supposed to do anything except return what's being passed in. Just seemed like a safe choice)

It feels like I'm missing an obvious step here.

Comments

Julian Matthews  Jan 5 to Enrico Parisi

The linked samples are very helpful, thank you!

0
Vitaliy Serdtsev · Jan 2

gateway.new() calls a constructor, but the System.Convert class has no constructors.

To call a static method, use gateway.invoke(), but keep in mind that if you call the following code, an error will occur <FONT COLOR=red>"Unable to resolve method overloading ambiguity":

write netGate.invoke("System.Convert","ToBoolean",123)

To avoid it, specify the name of the method with the full specification of the parameters, for example:

gw $System.external.getDotNetGateway()
gw.invoke("System.Convert","ToBoolean(int)",123),! ; -> 1
gw.invoke("System.Convert","ToBoolean(string)","false"),! ; -> 0
gw.invoke("System.Convert","ToBoolean(string)","true"),! ; -> 1

PS: see Mapping Specification (pay special attention to the sections "Overloaded Methods" and "Restrictions")

0
Julian Matthews  Jan 5 to Vitaliy Serdtsev

Ahh, I see. So I was trying to call a static method as if it was a constructor. Thank you for showing me this!

Interestingly, if I try your examples, I can recreate the ambiguity error, but then get an error when attempting to specify the full param specification:

Method not found: System.Convert.ToBoolean(int)

However this + the reply from Enrico has got me on a good footing, so will try a few things and see where I land.

0
Vitaliy Serdtsev  Jan 5 to Julian Matthews
Interestingly, if I try your examples, I can recreate the ambiguity error, but then get an error when attempting to specify the full param specification
What is your version of IRIS and .NET? I have IRIS 2025.3CE and .NET 8.0/Framework 4.6.2 - the examples above work flawlessly and give respectively 1, 0, 1 as indicated in the comments.

This is also possible:

USER>gw $System.external.getDotNetGateway()
USER>gw.invoke("System.Convert","ToBoolean(System.UInt64)",123)
1
USER>
0
Julian Matthews  Jan 5 to Vitaliy Serdtsev

.NET 6 and IRIS 2022.1.

As "w gw.invoke("System.Convert","ToBoolean(System.UInt64)",123)" also doesn't work for me, I have to assume there's an issue with my older versions.

Thanks again for your help!

0