CCW type project, can also be called from Managed?

OK, I have put together a scenario where I have a Native Console COBOL program code calling (invoking) a Managed Win-Forms COBOL program code (class/method).  This was based on the CCW tutorial plus lots of additional assistance with things like Interfaces (thanks all!).  I have attached what I have so far in 2 zip files (2 different solutions - one for the caller and one for the called).

My question is:  How would I also "call / invoke" this very same code from another Managed program code (class/method) - (another Managed solution) ???

ManWin1.zip
  • Verified Answer

    It is actually much easier to call the managed WinForm app from another managed program as you do not go through the extra COM Interop layer.

    Add a new managed console project to your ManWin1 solution called ManCon1 and add a reference to the ManWin1 project by right-clicking on References-->Add Reference then choose Solution and select the ManWin1 project and save.

    Then paste the following code into the new Program1.cbl that was created.

           program-id. Program1 as "ManCon1.Program1".
    
           data division.
           working-storage section.
           01  junk                        pic x(01).
           01  anInstance     type ManWin1.vcClass.
           01  passed-info.
               05  passed-info-1           pic x(20).
               
           procedure division.
    
               display spaces upon crt.
               display "ManCon1 managed Console Program..." at 0303.
               display
                "...calling (invoking class method in) ManWin1..." at 0503.
           
               set anInstance to new ManWin1.vcClass
               move "this is passed info" to passed-info.
               invoke anInstance::method1(passed-info)
               
               
               display "...back from ManWin1..." at 0703.
               display "Press Enter to exit..."  at 0803.
               accept junk at 0903.
               
               goback.
    
           end program Program1.