Show Contents / Index / Search

Create a New Session

This sample program creates a completely new host session without an existing Reflection 2011 session file.

The session is created by getting a control object, which contains only the data of a session and, by itself, isn't visible. (To make a session visible, you must also create a View object.)

To create a new session

  1. Start Reflection 2011.
  2. In Visual Studio, create a new Console Application project.
  3. In the New Project dialog box, type Create New Session in the Name box.
  4. Select the Create directory for solution box, click Browse to select your API projects folder (for example, C:\MyProjects), and then click OK.
  5. In Solution Explorer, add the class assemblies. (For instructions, see Create an API Project.)
  6. Copy the code from one of the following programs:

    Create New Session (IBM)

    Create New Session (OpenSystems)

  7. In Visual Studio, paste the code to the Program.cs tab, replacing all existing code.
  8. Note the following operations in this program (examples below are for IBM hosts).

    Get an application object:

    Attachmate.Reflection.Framework.Application reflectionApplication = MyReflection.CreateApplication("myWorkspace", true);

    Create a control object for a 3270 terminal session:

    IIbmTerminal terminal = (IIbmTerminal)reflectionApplication.CreateControl(new Guid("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}"));

    Connect to the host:

    terminal.HostAddress = "[MyHost]";


    Wait for the host screen to settle:

    screen.WaitForHostSettle(6000, 3000);

    Get text from the session screen (row 18, column 2, text string length 48):

    string text = screen.GetText(18, 2, 48);

    Write the text to a console window:


  9. Build the application (Build > Rebuild Solution) and then run it (Debug > Start Without Debugging).

    A console window should appear, displaying text from a session.