Question
· Feb 28, 2020

Cannot invoke %SYSTEM.OBJ.LoadStream() by IRIS.ClassMethodStatusCode

trying importing classDefinition to Iris via LoadStream() fails with
zLoadStream+1^%SYSTEM.OBJ.1 ----> InterSystems.Data.IRISClient.IRISException : Exception thrown on server (code = 1192)...

Code is here; use any valid exported ClassDefinition as File to test that:

    public static void loadClassFromStream(this IRIS iris, string txt)
    {

        // IRISObject globalCharStr = IrisStreamExtensions.FromTxt(iris, text);
        var fp = @"C:\tmp\TestClass.xml";
        txt = File.ReadAllText(fp);

        var stream = new MemoryStream();
        var bytes = Encoding.Default.GetBytes(txt);
        stream.Write(bytes, 0, bytes.Length);
        stream.Flush();
        stream.Position = 0;

        var qspec = "/display=none /compile=0 /recursive=0 /relatedclasses=0 /subclasses=0";
        var errorlog = "";
        var loadedItems = "";

        var parameter = new object[]
        {
            stream, 
            qspec,  
            errorlog,
            loadedItems
        };

        try
        {
            iris.ClassMethodStatusCode("%SYSTEM.OBJ", "LoadStream", parameter);
        }
        catch (Exception e)
        {
            throw new IrisException("%SYSTEM.OBJ", "LoadStream", e);
        }            

    }
Discussion (6)2
Log in or sign up to continue

byte[] content = (binary content of exported xml file)
string flags = "/compile=1"

var iris = IRIS.CreateIRIS(cn);
string text = System.Text.Encoding.UTF8.GetString(content);
IRISObject stream = (IRISObject)iris.ClassMethodObject("%Stream.GlobalCharacter", "%New");
stream.InvokeVoid("Write", content);

iris.ClassMethodStatusCode("%SYSTEM.OBJ", "LoadStream", stream, flags, errorlog);

Sorry, las reply was wrong
stream.InvokeVoid("Write", text)

byte[] content = (binary content of exported xml file)
string flags = "/compile=1"

var iris = IRIS.CreateIRIS(cn);
string text = System.Text.Encoding.UTF8.GetString(content);
IRISObject stream = (IRISObject)iris.ClassMethodObject("%Stream.GlobalCharacter", "%New");
stream.InvokeVoid("Write", text);

iris.ClassMethodStatusCode("%SYSTEM.OBJ", "LoadStream", stream, flags, errorlog);