Previous Topic Next topic Print topic


To run a .NET COBOL application from a network server

You can deploy a .NET COBOL application on a network server so that all workstations that are mapped to the server can run the application without the need to install Enterprise Server locally on each workstation.

Before you can configure your .NET COBOL application, ensure that:

If your application also uses native code components, you need to setup the licensing and create some shared folders - see To run a native COBOL application from a network server.

Note: The following folders in the installation of Enterprise Server on the server include:
  • %ProgramFiles(x86)%\Micro Focus\Enterprise Server\bin contains the native run-time files for 32-bit machines
  • %ProgramFiles(x86)%\Micro Focus\Enterprise Server\bin64 contains the native run-time files for 64-bit machines
  • %ProgramFiles(x86)%\Micro Focus\Enterprise Server\redist\v4.0 contains the .NET Framework version 4.0 of run-time assemblies
  • %ProgramFiles(x86)%\Micro Focus\Enterprise Server\redist\v2.0 contains the .NET Framework version 2.0 of run-time assemblies

Locating the .NET assemblies

When running a .NET COBOL application from a network server, you need to ensure the appropriate .NET run-time assemblies are available to the application.

The mechanism for locating and loading .NET assemblies at run-time is different to the one used for native .dlls. Native applications use the PATH system environment variable to locate dependent assemblies. For .NET COBOL applications, the required COBOL run-time assemblies must be in the same folder that contains your application files in order for the application to locate them. To ensure this:

  1. Either copy the appropriate run-time assemblies from the redist\v4.0 or redist\v2.0 folders in the Enterprise Server installation location into your application folder, or copy your application files into the appropriate redist\* folder in the Enterprise Server installation location.
  2. Create a network share for the folder that contains your application files and the COBOL run-time assemblies, then make the network share available to your workstations.

    For example, share %ProgramFiles(x86)%\Micro Focus\Enterprise Server\redist\v4.0 if you copied the application to it. If your application targets .NET Framework v2.0, then share the \redist\v2.0 folder.

This approach is not applicable to the scenario where your application uses the standard COBOL CALL mechanism to load the dependent assemblies - for example: set <procedure-pointer> to entry "progname" or call "progname". Programs loaded in this way are located using the PATH environment variable. To make deployment easier, Micro Focus recommends that you keep all dependent .NET assemblies within the same folder.

If you are setting the PATH environment variable to locate any called assemblies in this case, Micro Focus recommends you set the variable directly in your app.config file and not at system level. For example, your app.config file should look like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!--The following code declares a section group for application configuration -->
    <sectionGroup name="MicroFocus.COBOL.Application">
      <section name="Switches" type="System.Configuration.NameValueSectionHandler" />
      <section name="Environment" type="System.Configuration.NameValueSectionHandler" />
    </sectionGroup>
    <!--The following code declares a section group for run-time configuration -->
    <sectionGroup name="MicroFocus.COBOL.Runtime">
      <section name="Tunables" type="System.Configuration.NameValueSectionHandler" />
      <section name="Switches" type="System.Configuration.NameValueSectionHandler" />
    </sectionGroup>
  </configSections>
  <MicroFocus.COBOL.Application>
    <Switches />
    <Environment>
      <add key="PATH" value="F:\myappfiles;%PATH%" />
    </Environment>
  </MicroFocus.COBOL.Application>
</configuration>

Network security considerations

By default, network drives only have "local intranet" permissions which restricts a lot of the operations you might want to do on them. This is why, when running a .NET COBOL application from a network share, you need to elevate its security level. You can do this in one of the following ways:

  • Add an app.config file to the application which includes the following code that provides full trust to assemblies on the network share:
    <runtime>
        <loadFromRemoteSources enabled="true"/>
    </runtime>
    

    For example:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <!--The following code declares a section group for application configuration -->
        <sectionGroup name="MicroFocus.COBOL.Application">
          <section name="Switches" type="System.Configuration.NameValueSectionHandler" />
          <section name="Environment" type="System.Configuration.NameValueSectionHandler" />
        </sectionGroup>
        <!--The following code declares a section group for run-time configuration -->
        <sectionGroup name="MicroFocus.COBOL.Runtime">
          <section name="Tunables" type="System.Configuration.NameValueSectionHandler" />
          <section name="Switches" type="System.Configuration.NameValueSectionHandler" />
        </sectionGroup>
      </configSections>
      <runtime>
          <!--The following line provides Full Trust for assemblies loaded from a network share -->
          <loadFromRemoteSources enabled="true"/>
       </runtime>
    </configuration>
    
  • Alternatively, use Microsoft's caspol (Code Access Security Policy) tool on the share that contains your application. See Microsof's MSDN for more information about how to do this.
Previous Topic Next topic Print topic