Opening multiple Reflection Host sessions with the .NET API results in all sessions opening in the same Workspace

  • 7024769
  • 04-Aug-2020
  • 26-Mar-2021

Environment

Reflection Desktop (including Pro, for IBM or for UNIX and OpenVMS) 16.0 or higher

Situation

When opening multiple Reflection Desktop Host sessions with the .NET API, all the host sessions open in the same Workspace, instead of individual Reflection Workspaces as expected.  A .NET API application has been written in C#, which uses unique IPC Channel names for launching multiple Reflection “Frames” and opening a Host session in each one.  When using this methodology, the unique IPC channel names should cause each Host session to open in its own Reflection Workspace.  With Reflection Desktop 16.1 (and Reflection Desktop 16.1 SP1) this occurs, each host session launched ends up in its own Workspace.  Starting with Reflection Desktop 16.2 (all the way through Reflection Desktop 16.2 Update 4) instead of this happening, each host session launched ends up in the same Workspace, which can cause problems when individual Host sessions are opened and closed.

Resolution

To work-around this issue with Reflection Desktop 16.2 and higher, call MyReflection.Start() before calling MyReflection.CreateApplication() which will create separate Workspaces whether the IPC channels are the same or different:

Existing code which fails:
    Int ran = rnd.Next(1,10000);
    Attachmate.Reflection.Framework.Application reflectionApplication = MyReflection.CreateApplication("myWorkspace" + ran.ToString(), true);

Updated code which will resolve the issue:
    Int ran = rnd.Next(1,10000);
    MyReflection.Start(("myWorkspace" + ran.ToString())
    Attachmate.Reflection.Framework.Application reflectionApplication = MyReflection.CreateApplication("myWorkspace" + ran.ToString(),true);

This issue will be resolved in Reflection Desktop 17.0 and higher and will no longer require the workaround.  But if the MyReflection.Start() method has already been added to the code, this will still work correctly in future releases of Reflection Desktop.

Additional Information

Modifying the Reflection Workspace setting for “Open documents in same workspace” as both checked and unchecked, will not make a difference to this problem.

Here is the source code for a test application to duplicate the issue:

using System;
using Attachmate.Reflection.Emulation.OpenSystems;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.UserInterface;

class RDtest

     public static void Main(String[] args)
    {
       String settingsA = @args[0];
       String settingsB = @args[1];
       String ipcChannelA = args[2];
       String ipcChannelB = args[3];
       Boolean isVisible = true;

       Console.WriteLine("Launching first instance of Reflection ...");

       // Uncomment the following line to make this sample application work properly
       //MyReflection.Start(ipcChannelA);
       Application appA = MyReflection.CreateApplication(ipcChannelA, isVisible);
       IFrame frameA = (IFrame)appA.GetObject("Frame");
       ITerminal terminalA = appA.CreateControl(settingsA) as ITerminal;
       frameA.CreateView(terminalA);

       Console.WriteLine("Launching second instance of Reflection ...");

       // Uncomment the following line to make this sample application work properly
       //MyReflection.Start(ipcChannelB);
       Application appB = MyReflection.CreateApplication(ipcChannelB, isVisible);
       IFrame frameB = (IFrame)appB.GetObject("Frame");
       ITerminal terminalB = appB.CreateControl(settingsB) as ITerminal;
       frameB.CreateView(terminalB);

       Console.WriteLine("Testing the .NET API with each session");

       terminalA.Screen.DisplayText("Session: " + settingsA + "\r\nChannel: " + ipcChannelA);
       terminalB.Screen.DisplayText("Session: " + settingsB + "\r\nChannel: " + ipcChannelB);
  }
}

Feedback service temporarily unavailable. For content questions or problems, please contact Support.