Question
· Aug 23

.NET External language server and output variables (IRISReference)

Hello, 

I'm working on building some .NET Scripts/CLI tools and starting to use the .NET external language server.

I've been able to connect using the .NET SDK, but trying to understand a little how to make a call that has a output parameter. I've read that you should use IRISReference, but haven't been able to get that to work. Here is what I'm trying to do

I'm trying to make a call to the %SYS.Namespace.ListAll() method but as you will note, the first param for the method is an output param (https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.D...)

If you read the https://docs.intersystems.com/irisforhealth20242/csp/docbook/DocBook.UI....
it references you should use IRISReference and then use that object when passing into the method. Example below

  IRISReference valueRef = new IRISReference(""); // set inital value to null string
  iris.ClassMethodString("%SomeClass","SomeMethod",valueRef);
  String myString = valueRef.value;               // get the method result

In my code I'm using the following, but receive a message of "Index was outside the bounds of the array." How should I be using the IRISReference object when the parameter expects an Output like the above %SYS.Namespace.ListAll() method

using InterSystems.Data.IRISClient;
using InterSystems.Data.IRISClient.ADO;

IRISConnection Conn;

try
{
    Conn = new IRISConnection();
    Conn.ConnectionString = "Server=myserver; Port=1972; Namespace=%SYS;Password=password; User ID=username";
    Conn.Open();

    IRIS iris = IRIS.CreateIRIS(Conn);
    IRISReference a = new IRISReference("");

    iris.ClassMethodStatusCode("%SYS.Namespace","ListAll",a);
    Conn.Close();
}
catch (Exception eConn)
{
    //this returns Index was outside the bounds of the array.
    Console.WriteLine(eConn.Message);
}
Product version: IRIS 2024.1
Discussion (3)2
Log in or sign up to continue