Calling Cobol 5.1 GNT from Visual Cobol dynamically at runtime

We have a Cobol 5.1 Menu system that calls one of 1,000’s of application gnt programs depending on option chosen.

We want to create a graphical menu system in Visual Cobol that can call the existing Gnt applications.

 

I have created a simple test program that accepts a folder name and a program name then calls the requested program. The test program works fine until I call the test gnt program.

The test program was compiled using visual Cobol command line compile to produce the GNT application.

 

The call results in the error:

FAILMicroFocus.COBOL.COBOLRuntimeException: 174     Imported file not found

(Could not load file or assembly 'file:///C:\Silverlink\v3.9\wintne\lib\restest.gnt' or one of its dependencies. The module was expected to contain an assembly manifest.) ---> System.BadImageFormatException: Could not load file or assembly 'file:///C:\Silverlink\v3.9\wintne\lib\restest.gnt' or one of its dependencies. The module was expected to contain an assembly manifest.

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)

   at System.Reflection.Assembly.LoadFrom(String assemblyFile)

   at MicroFocus.COBOL.Runtime.Win32.PlatformAbstraction.LoadFrom(String assemblyFile)

   at MicroFocus.COBOL.Runtime.BaseFinder.LoadAssembly(RunUnit runUnit, String assemblyName, Boolean hasEvidence)

   --- End of inner exception stack trace ---

   at MicroFocus.COBOL.Runtime.BaseFinder.LoadAssembly(RunUnit runUnit, String assemblyName, Boolean hasEvidence)

   at MicroFocus.COBOL.Runtime.LoadAndSearchAssembly.FindProgram(RunUnit runUnit, ProgramName progName)

   at MicroFocus.COBOL.Runtime.BaseFinder.Action(Object obj)

   at MicroFocus.COBOL.Runtime.Common.PrioritizedList.Action(Object actionData, Boolean remove)

   at MicroFocus.COBOL.Runtime.ProgramFinder.FindProgram(RunUnit runUnit, ProgramName progName)

   at MicroFocus.COBOL.Runtime.Common.RunUnit.GetLoadedOrNewProgram(String program, Object& instance)

   at MicroFocus.COBOL.Program.ProcedurePointer.CreateProcedurePointer(RunUnit runUnit, String programName)

   at MicroFocus.COBOL.Program.ProcedurePointer.GetProcedurePointer(RunUnit runUnit, String name)

   at MicroFocus.COBOL.Program.Control.CallReturningObject(UInt32 callConvention, String program, Object[] parameters, IObjectControl pgInstance)

   at MicroFocus.COBOL.Program.Control.Call(UInt32 callConvention, String program, Object[] parameters, IObjectControl pgInstance)

   at libtest.Form1.Callprog_Click(Object sender, EventArgs e) in L:\v3.9\wcbl\lib\libtest\Form1.cbl:line 92

 

Source code available if required.

VCMailMerge.zip