Skip to main content

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
You might want to look at our sample\\dotnet\\netdb directory and sample as that seems to match closely to what you are attempting to do.

CREATE "NetDB"
NAMESPACE IS "NetDB",
CLASS-NAME IS "NetDB_MGR",
CONSTRUCTOR IS CONSTRUCTOR1(DB-PATH, QUERY-STRING),
HANDLE IS MY-ASSY-HANDLE.


Create "TEST"
NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"
CONSTRUCTOR IS CONSTRUCTOR1()
HANDLE IS TEST-HANDLE.

MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
Thanks for the reply, I still get the compile error: Undefined dataitem: NAMESPACE.
How do I resolve this?

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
Thanks for the reply, I still get the compile error: Undefined dataitem: NAMESPACE.
How do I resolve this?

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
The def file has this, NAMESPACE "TestNS" does it error when using that?

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
It does not indicate that the error is with the def file. It indicates that the error is right after the create.

Create "TEST"
NAMESPACE IS "TESTNS" <-------
CLASS-NAME IS "ClassName"
CONSTRUCTOR IS CONSTRUCTOR1()
HANDLE IS TEST-HANDLE.

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
Can you attach the dll and def file or make a zip file and send it to stephen.hjerpe@microfocus.com

I am trying to call a method within my c# dll.

I have generated the dll and I have created the def file from that dll. That all works fine.

The problem is the COBOL implementation. I am using ACUCOBOL 10.0.1.

I am unsure how to call my dll method.

DEF-file:

      >>IMP(ACU-CBLFLAGS=-Sl)

           OBJECT @ASSEMBLY
           NAME    "@Test"
           VERSION "1.0.0.0"
           CULTURE "neutral"
           STRONG  "null"

      * TestNS.ClassName
           NAMESPACE "TestNS"
           CLASS     "ClassName"
           MODULE    "Test.dll"

           CONSTRUCTOR, 0, @CONSTRUCTOR1

      * [Class: ClassName] System.String Method1(System.String, System.String, System.String)
           METHOD, 0, "@Method1"
               "BSTR" @param1, TYPE 8
               "BSTR" @param2, TYPE 8
               "BSTR" @param3, TYPE 8
           RETURNING "BSTR", TYPE 8

 

I loaded the def file in cobol and I have registered the dll using regasm.

       COPY "TEST.DEF".  

       01  Call-params.
         05  Param1     PIC X(12).
         05  Param2        PIC X(200).
         05  Param3   PIC X(100).
     
       77  RESULT     PIC X(100).

 

77  TEST-HANDLE HANDLE OF "@Test.TestNS.ClassName".

           CREATE "@Test"
  
           MODIFY TEST-HANDLE "@Method1" (Param1, Param2, Param3) GIVING RESULT.

 

I have also tried with Create "@Test" HANDLE IS TEST-HANDLE, but that gives an internal error #45, which I could not resolve.

When I try with  

NAMESPACE IS "TESTNS"
CLASS-NAME IS "ClassName"               
CONSTRUCTOR IS CONSTRUCTOR1()

 

I get undefined data-item namespace.

I seems like I can see the dll, but I cannot call the method inside it.

 

I don't have very much experience with COBOL yet.

I have tried to look at the samples that micro focus provides, but I can't seem to make them work for my project.

Is it possible to call a c# console application dll from cobol? if so, how do I do it?

There is no GUI. All I am doing is collecting some information (Using a .net library) and writing it to a file.

Any help is appreciated.


#AcuCobol
#C
#.net
#COBOL
#c
The problem was a compatibility issue, I was compiling the source backwards compatible to version 6.1. changing this resolved the problem.