Reflection .NET API
Get Started / Open a Session
In This Topic
    Open a Session
    In This Topic

    You can open session document files that were created in previous sessions. This sample program uses the CreateControl() to create a session from a saved session document file. (For other ways to get terminal sessions, see Getting Terminal and View Objects.)

    To create a session from a session document file

    1.   Create a session and save it as "gettingStarted" (for example, gettingStarted.rd3x) in the default folder (...\myDocuments\Micro Focus\Reflection).         
    2. In Visual Studio, create a new Console Application project and add references for the following Reflection assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
      Attachmate.Reflection.Framework
      Attachmate.Reflection.Emulation.IbmHosts
      Attachmate.Reflection.Emulation.OpenSystems
      Attachmate.Reflection

    3. Replace all the code in the Program.cs file with the following code for the terminal you are using.

                                   

      Open a session
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Text;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.IbmHosts;
      using Attachmate.Reflection.UserInterface;
      
      namespace OpenASession
      {
          class Program
          {
              static void Main(string[] args)
              {
                  //Start a visible instance of Reflection or get the instance running at the given channel name
                  Application app = MyReflection.CreateApplication("myWorkspace", true);
      
                  //Create a terminal from the session document file
                  string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\gettingStarted.rd3x";
                  IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(sessionPath);
      
                  //Make the session visible in the workspace
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  frame.CreateView(terminal);
              }
          }
      }  
                                       
      
                                              
      

                                

                              

      Open a session
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Text;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.OpenSystems;
      using Attachmate.Reflection.UserInterface;
      namespace OpenASession
      {
          class Program
          {
              static void Main(string[] args)
              {
                  //Start a visible instance of Reflection or get the instance running at the given channel name
                  Application app = MyReflection.CreateApplication("myWorkspace", true);
      
                  //Create a terminal from the session document file
                  string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\Reflection\gettingStarted.rdox";
                  ITerminal terminal = (ITerminal)app.CreateControl(sessionPath);
      
                  //Make the session visible in the workspace
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  frame.CreateView(terminal);
      
              }
          }
      }
      
      

    To test this project