Question Stefan Rieger · Feb 28, 2020

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

trying importing classDefinition to Iris via LoadStream() fails with <INVALID OREF>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);
        }            

    }

Comments

Eduard Lebedyuk · Feb 28, 2020

Use byte[] to pass streams. So:

byte[] bytes = Encoding.Default.GetBytes(txt);
...
var parameter = new object[]
        {
            bytes,
            qspec,  
            errorlog,
            loadedItems
        };
0
Stefan Rieger  Feb 28, 2020 to Eduard Lebedyuk

unfortunately results with same error: <INVALID OREF>zLoadStream+1^%SYSTEM.OBJ.1.... as far as i can see it's thrown at InterSystems.Data.IRISClient.InStream.readHeaderSYSIO(Int64 msgid, List`1 allowedErrors)

Any Ideas?

0
Eduard Lebedyuk  Feb 28, 2020 to Stefan Rieger

I'd recommend:

  1. Write LoadStream method with the same signature which logs all passed arguments.
  2. Call it from .Net
  3. Check what's actually gets passed inside.
0
Stefan Rieger  Feb 28, 2020 to Eduard Lebedyuk

good idea; i can see the point now: As %SYSTEM.OBJ.LoadStream() Method checks if Parameter <stream.IsCharacter> it fails as the parameter is passed as "No-Object". With 2019 libs i had the opportunity to pass in native CacheObjects - that's not possible with this architecture and IRISObjects?

0
David Yerga · Jan 16

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);

0
David Yerga · Jan 16

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);

0