Skip to main content

Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Yes, a Net Express application can call a managed code .NET application if that .NET application is registered for COMInterop which is a property setting in the .NET Build.

Then the VB.NET program can be called as if it were a COM Server in the same manner that you show in your example.

There is an example of how to call a Visual COBOL .NET managed code program from a Net Express program here:
Calling a VB.NET program works the same way.

Thanks


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi Chris,

I did the above and am getting 'exception 65537 not trapped by the class of oleexceptionmanager. server defined OLE exception Invalid class string.  Cannot bind to server geocode.clsLocation.'

I compiled the geocode with the property and then moved the dll to the EBIX subdir where I thought it picked these dlls up.  Does it have to do with registering?  If so, how do I tell if something is registered?

Any ideas?  

Thanks,

Fran D.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

When the VB project is registered for COM by Visual Studio, certain Registry entries are created that point to the location of the .dll on disk in its current location so it should not be moved.

The COM client will find the .dll when it is instatiated by looking up its location and interface in the COM Registry entries.

The Net Express IDE has a tool called the Type Library Assistant that can be very useful in creating a COM client in COBOL.

After building your VB COM Server start the Net Express IDE and select Tools-->Type Library Assistant from the main menu,
Scroll down the list of registered type libraries and look for the name of your Visual Basic class starting with its project name which is by default the namespace followed by the class name.

Example, if your VB project is called vbCOMServer and the class is vbCOMClass then the name in the list would be vbCOMServer.vbCOMClass.
Double-click on the class name in the list to show a dialog like the following:

Check the boxes as shown above and click on Generate to create a copybook named TypeLib.cpy in your Net Express project.

If you open up this copybook it will show the class and method definitions as they should appear in your COBOL client.
Look for the line with the class definition which is commented out:

*> ==========================                                    
*> = Type library contents: =                                    
*> ==========================                                    
*> Name: vbCOMServer                                             
*>                                                               
                                                                 
*> FOUND CLASS: "vbCOMClass".                                    
*> vbCOMClass is class "$OLE$vbCOMServer.vbCOMClass".            

The line directly above is what you should use in your COBOL client.

Here is an example:

   

      $set OOCTRL( P)                                              
       id division.                                                
       program-id.   CALLVB.                                       
       environment division.                                       
       class-control.                                              
          vbCOMClass is class "$OLE$vbCOMServer.vbCOMClass".       
       data division.                                              
       working-storage section.                                    
       01 vbclass object reference.                                
       01 mystring  pic x(20)  value "from COBOL".                 
       01 any-key   pic x.                                         
       procedure division.                                         
                                                                   
            invoke vbCOMClass "New" returning vbclass              
            invoke vbclass "vbMethod" using mystring               
            invoke vbclass "Finalize" returning vbclass.           
            display mystring                                       
            accept any-key                                         
            stop run.



and the VB class that this is calling looks like the following:

Public Class vbCOMClass
    Public Function vbMethod(ByRef mystring As String)
        mystring = "Hello from VB"
        Return 0
    End Function
End Class

Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi Chris,

Thanks for all of the detailed info!

Unfortunately, I noticed that on the build of the dll using the com property, I get:

Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.

I am not sure what this means, although I have tried looking up more info on it, or how to fix it...


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Also, in the list of type libraries, I find nothing that resembles my Visual Basic class starting with its project name...


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

You are not seeing the VB.NET class in the list because it didn't build successfully for COM Interop.
What version of Visual Studio are you using?

I am not an expert in Visual Basic but I googled the message you are getting and it returned many hits including the following which are quite good.

www.codeproject.com/.../Exposing-NET-Components-to-COM

msdn.microsoft.com/.../4fcadw4a.aspx

You might try adding something like the following to your VB code:

Imports System.Runtime.InteropServices

<ClassInterface(ClassInterfaceType.None)> _
Public Class vbCOMClass
    Public Function vbMethod(ByRef mystring As String)
        mystring = "Hello from VB"
        Return 0
    End Function
End Class

Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi,

Yes I had googled it, but it really doesn't make sense to me.  I added the

Imports System.Runtime.InteropServices

and

<ClassInterface(ClassInterfaceType.None)>

and it seems to build now without errors, but I still don't see it in the type list.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

What version of Visual Studio are you using for your Visual Basic .NET application?

Are you starting it with Administrative permissions?

When I test here using Visual Studio 2010 under Windows 7 using the example that I posted for you, all works fine for me...

Thanks.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi,

I'm using Visual Studio 2010 under Window 7 also.  I just started VS 2010 as admin (hadn't before) and rebuilt the geocode project, got no errors, but still don't see it in net express (tools, type lib assistant).

I changed the VB in geocodeinfo.vb to:

Imports System.Collections

Imports System.ComponentModel

Imports System.Runtime.InteropServices

<ClassInterface(ClassInterfaceType.None)> _

Public Class GeoCodeInfoCollection

   Inherits ObjectModel.Collection(Of GeoCodeInfo)

and in geocodesearch.vb to:

Imports System.Runtime.InteropServices

#Region "Enums"

Public Enum GeoCodeStatus

   Initialized

   CompleteNoMatches

   CompleteOneMatchNotClose

   CompleteOneMatchClose

   CompleteMultipleOneClose

   CompleteMultiple

   Failed

End Enum

#End Region

<ClassInterface(ClassInterfaceType.None)> _

Public Class GeoCodeSearch


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

It may have to do with how it is registered - as I tried doing this before I knew it was done automatically.  Tried to unregister it using the 32 bit version (I get : the module may not be compatible with the version of windows that you are running.  Check if compatible with x86 or x64 version of regsvr32.exe.  Tried to unregister is  (from syswow64) using 64 bit version and I get: the module was loaded but the entry-point dllunregisterserver was not found.  make sure module is a valid dll or ocx file...


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

You cannot use regsvr32 to register .NET assemblies, you must use regasm instead.
Please see the following article which is for Visual COBOL but it also applies to VB.NET as well.

community.microfocus.com/.../22925.visual-cobol-native-program-calls-net-managed-via-com-interop-fails-when-run-under-cobol-server.aspx

I have also attached the simple VB solution that I am using here so that you can test this with a project that I know works on my computer.
Please start Visual Studio as administrator and then open and rebuild the solution.

Then create a Net Express program that does the following:

 

      $set OOCTRL( P)                                                
       id division.                                                  
       program-id.   CALLVB.                                         
       environment division.                                         
       class-control.                                                
          vbCOMClass is class "$OLE$vbCOMServer.vbCOMClass".         
       data division.                                                
       working-storage section.                                      
       01 vbclass object reference.                                  
       01 mystring  pic x(20)  value "from COBOL".                   
       01 any-key   pic x.                                           
       procedure division.                                           
                                                                     
            invoke vbCOMClass "New" returning vbclass                
            invoke vbclass "vbMethod" using mystring                 
            invoke vbclass "Finalize" returning vbclass.             
            display mystring                                         
            accept any-key                                           
            stop run.                                                

Does this work on your system?

Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Yes, it did work...but my com module is still not showing up in net express, type library assistant...


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Just found out that the com module is calling a .net library and Saurabh thinks that probably a com module can't talk to a .net library.   Do you know if this is the case, or could there be around it?  Thanks.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

I do not believe that this would be an issue here as you are registering the .net library as a COM component so it is a COM client on the Net Express side calling a COM Interop layer on the .net side.

Perhaps you need to define an explicit interface in your VB code and declare it with the COMVisible attribute?

Here is a link that I found that explains this process, albeit in an older version of VB.

Thanks.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi Chris,

I think I didn't explain this well.  In the Geocode project:

Imports CdNetRmClientDll

Public Class GeoCodeSearch

#Region "Variables"

   Private _RmHttpService As CdNetRmClientDll.RmHttpService

   Private _Results As New GeoCodeInfoCollection

   Private _CloseResults As New GeoCodeInfoCollection

   Private _Status As GeoCodeStatus

   Private _ErrorMessage As String

#End Region

Private Sub InitializeRiskMeter()

       Dim ResponseTimeout As Integer = 60

       Dim MaintainSession As Boolean = False

       With My.Settings

           Me._RmHttpService = New CdNetRmClientDll.RmHttpService(.RmServiceAddr, _

          .GeoCodeUserId, .GeoCodePassword, .MemberId, .Environment, ResponseTimeout, MaintainSession)

       End With

       Me._Status = GeoCodeStatus.Initialized

   End Sub


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Any ideas on if this can be done?  Thanks.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Hi, any idea if the above can be done?  Thanks.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

What your short sample demonstrates is how to call a COM Server from a native Net Express program.

The language in which the COM Server is written is irrelevant to Net Express.

If you have a VB.NET class that is being built as a COM Server using COMInterop then it would be called from a Net Express native program in exactly the same manner as your VB6 COM Server.

This is known as CCW or COM Callable Wrapper in the .NET world.

CCW wraps managed code as a COM object so that native code can call it like any other COM object.

It effectively exposes a .NET managed class in any language as a COM interface. For more background, see the MSDN Help topic COM Callable Wrapper.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Well, I am not sure what or where the problem is.  But I can't get it to create a registered type library that I can call from Net Express.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Are you able to call this same COM server from a non-COBOL application like from a different VB.NET application that adds a reference to the type library?

If not then the issue seems to be related more to the correct creation of the COM server in VB.NET than it does with being able to call it in Net Express.

Have you checked with Microsoft on this?


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Finally got this to (almost) work. Thanks for all of your help!


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

I did get the NetExpress COBOL program to instantiate, call and then destroy the com module -  unfortunately the COBOL program is not getting information back via the return code (even though I send info to the COM module that I know will result in a legit return code).  I created a test to call the module (giving it the same parameters) in VB.net and it works there.    Any ideas of how I can find out what is going wrong - or where?


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

Can you show me what the COBOL invoke looks like for the method you are calling and also the VB method definition?

Thanks.


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

In COBOL (I edit the parms)

Instantiate:   invoke GeoCodeSearch "new" returning geosearch.  

Call: invoke geosearch "inBounds"  using crm-street-address1

                                  crm-city          

                                  crm-state          

                                  crm-zipcode,      

                                  crm-result.        

Destroy:   invoke geosearch "Finalize" returning geosearch.  

In VB.net:

Dim loc As New GeoCode.GeoCodeSearch

           Dim stest As String

           Dim Address As String = "264 SURF DRIVE", City1 As String = "FALMOUTH", State1 As String = "MA", Zipcode1 As String = "02540", cobret As String = ""

           stest = loc.Inbounds(Address, City1, State1, Zipcode1, cobret)

           MessageBox.Show("Pause", "Pause", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, 0)


Hi,

Can I call a managed VB dll from Cobol Net Express?  If so, how?

Here is a sample of how playet, a VB 6 dll, would be called by NE Cobol:

$SET OOCTRL( P)                                                         
 
  identification division.                                                
                                                                          
      program-id.   CALLPLAY.                                             
        
  environment division.                                                   
  class-control.                                                          
      playet is class "$OLE$playet.clsLocation".                    
  configuration section.                                                  
  special-names.                                                          
      call-convention 8 is llnk.                                          
     
  data division.                                                          
  working-storage section.                                                
                                                                          
                                                      
  01 work-area.                                                           
     05  playserver       object reference.                               
                                                                          
  linkage section.                                                        
  01 crm-linkage.                                                         
     05  crm-street-address1          pic x(30).                          
     05  crm-CITY                     pic x(20).                          
     05  crm-state                    pic x(02).                          
     05  crm-zipcode                  pic x(05).                          
     05  crm-Result                   pic x(01).                          
 
  procedure division using reference crm-linkage.                         
 
  mainline.                                           
                          
                                                                          
       invoke playserver "inBounds" using crm-street-address1             
                                          crm-city                        
                                          crm-state                       
                                          crm-zipcode                     
                                          crm-result.                     
 *destroy an instance of playet, i.e. playserver                       
         invoke playserver "Finalize" returning playserver.               
       
  finalization.                                                  
                                                                       
     exit program.     

I guess the question is why am I not getting the value of cobret (which i can see has been set when I run the vb code) in cobol?  I have even set it to 'x' in cobol before running the invoke, and it comes back null.