Hi
In our project earlier we were using a unmanaged DLL that was consumed by C . Now we are migrating from C to .NET. So the same DLL can not be consumed by .NET.
The problem statement:-
The COBOL program "Prog1" inside the DLL is having 4 Entry points.
As read from some of the threads we are trying to create a COBOL COM wrapper Class from File -> New->CLASS->COM Component.
This will create a new class in a new Net Express project. then We tried to create 4 method using Class wizard in this Class for all entry points.
1. Like Method1 for Entry1
2. Method2 for Entry2.
Now we are not able to understand how to make a call to existing (Prog1) COBOL program for an entry points in the Method.
We also tried the below option:
Method 1()
:declare in local storage of method 1
77 default-entry-point procedure-pointer.
:Code in Mehtod
set Default-Entry-point to entry "Prog1". (in an method1)
and then call the Entry point.
Call "Entry1" using
After this we compiled and build the Code and an DLL is created.
That DLL is registered using REGSVR32 and TILBIMP is doen for the same at .NET side.
Now when .NET tried to call MEthod1 after creating object of the Net Express Class.
We are getting an error 173 Called program not found in drive/directory.
Let us know where we are making mistake.
Thanks
Charan
I am attaching an example NX project that contains the following: (you must rebuild the project and register nxcomprog.dll:
addprog.dll
This consists of 4 programs that perform different arithmetic functions:
This is linked as dynamic multi-threaded and is a native .dll.
addprog.cbl
subprog.cbl
mulprog.cbl
divprog.cbl
nxcomprog.dll
This is the COM wrapper class that was generated by the NX wizard.
It contains 4 methods that can be called from a COM client that will call the appropriate entry points within addprog.dll.
AddMethod
SubMethod
MulMethod
DivMethod
I also added a New method to the class-object that will load the native .dll so that its entry points will be visible.
nxclient.exe
This is a client program that will instantiate nxcomprog and call its methods and display the result.
It is important to link the com wrapper .dll and the .dll that it calls using the same method, in this case dynamic and multi-threaded.
You should be able to call nxcomprog.dll from a C# program in the same manner.
Let me know if you have questions.
Thanks.
Hi
In our project earlier we were using a unmanaged DLL that was consumed by C . Now we are migrating from C to .NET. So the same DLL can not be consumed by .NET.
The problem statement:-
The COBOL program "Prog1" inside the DLL is having 4 Entry points.
As read from some of the threads we are trying to create a COBOL COM wrapper Class from File -> New->CLASS->COM Component.
This will create a new class in a new Net Express project. then We tried to create 4 method using Class wizard in this Class for all entry points.
1. Like Method1 for Entry1
2. Method2 for Entry2.
Now we are not able to understand how to make a call to existing (Prog1) COBOL program for an entry points in the Method.
We also tried the below option:
Method 1()
:declare in local storage of method 1
77 default-entry-point procedure-pointer.
:Code in Mehtod
set Default-Entry-point to entry "Prog1". (in an method1)
and then call the Entry point.
Call "Entry1" using
After this we compiled and build the Code and an DLL is created.
That DLL is registered using REGSVR32 and TILBIMP is doen for the same at .NET side.
Now when .NET tried to call MEthod1 after creating object of the Net Express Class.
We are getting an error 173 Called program not found in drive/directory.
Let us know where we are making mistake.
Thanks
Charan
Hi Chris,
I am able to run the Code provided by you. I have couple of questions/assumption regarding the Solution provided by you.
1. I think NXCLIENT.EXE file is created just to test this application from NX. This wont be part of .NET code base. We need to provide nxcomprog.dll to .NET only. Which they will register and and add as a reference in there code base. Is it right?
2. Have you created the addprog.dll via NX create packaged file option?
3. In nxcomprog.cbl file you have created a method NEW, Is this method created using Class wizard then selecting Method Type as Factory or instance?
4. in New method of nxcomprog.cbl, You have set the PP to entry "addprog" , Is addprog mentioned here is name of the native DLL or name of the starting program?
We have tried to build an project based on following requirement.
Our requirement :
1. We have one program Data.cbl. This program have 4 ENTRY(FData1,FCON1 etc.) points and all entry point perform some Function (Reading/writing files) and return data to .NET.
Following are the steps we have followed in building our solution based on your example.
1. First we created an native dll:-Fdata.dll, using Create packaged file option for program Data.cbl.
2. Then we created a class (COM Component). comclass.cbl.
3. Then we added following methods using class wizard ,
- new - A Factory method
- fetchD- A instance method using some linkage parameters.
4. Now we declared the Procedure Pointer PP and SET pp to entry "Fdata.dll" native DLL.
5. Now in fetchD method put a call for entry point in native DLL.
call "FData1" using Linkage. - Calling an entry Point in Data.cbl.
6. Then we have created comclient.cbl program same like nxcomprog.cbl.
7. Created comclient.exe using Create Packaged File otption.
8. Compiled the code and build the NX solution.
9. Run the comclassserver Registration Entries.
10. Register the COM comclass.dll , with Regsvr32 command.
Now when we try to run/animate it, At
Invoke comclass "new" returning aninstance
statement we are getting the following error.
"Dynamic Binding error on Runtime Entry Point oops"
" The Dynamic Binding requirement for this exe/dll are incompatable with the runtime library that is already loaded"
"The run-time library version(5.1) is already loaded from C:\\Pfile\\MicroFocus\\NX 5.1\\base\\bin\\cblrtss.dll"
"The dynamic binding for this EXE/DLL requires atleast version(5.1) of the Net Express runtime library OOPSM.DLL"
Let us know why we are getting this error.
Also let us know if we are making any mistake in this.
Thanks
Charan
Hi
In our project earlier we were using a unmanaged DLL that was consumed by C . Now we are migrating from C to .NET. So the same DLL can not be consumed by .NET.
The problem statement:-
The COBOL program "Prog1" inside the DLL is having 4 Entry points.
As read from some of the threads we are trying to create a COBOL COM wrapper Class from File -> New->CLASS->COM Component.
This will create a new class in a new Net Express project. then We tried to create 4 method using Class wizard in this Class for all entry points.
1. Like Method1 for Entry1
2. Method2 for Entry2.
Now we are not able to understand how to make a call to existing (Prog1) COBOL program for an entry points in the Method.
We also tried the below option:
Method 1()
:declare in local storage of method 1
77 default-entry-point procedure-pointer.
:Code in Mehtod
set Default-Entry-point to entry "Prog1". (in an method1)
and then call the Entry point.
Call "Entry1" using
After this we compiled and build the Code and an DLL is created.
That DLL is registered using REGSVR32 and TILBIMP is doen for the same at .NET side.
Now when .NET tried to call MEthod1 after creating object of the Net Express Class.
We are getting an error 173 Called program not found in drive/directory.
Let us know where we are making mistake.
Thanks
Charan
answers to your questions:
1. I think NXCLIENT.EXE file is created just to test this application from NX. This wont be part of .NET code base. We need to provide nxcomprog.dll to .NET only. Which they will register and and add as a reference in there code base. Is it right?
That is correct, nxclient.exe was only for testing that the COM server was working. It is not part of the actual COM Server. They will need nxcomprog.dll and the .dll that it calls which in this case is addprog.dll.
2. Have you created the addprog.dll via NX create packaged file option?
I did create it as a .dll using the package as option but then I changed the link settings to dynamic and multi-threaded so that it used the same options as the nxcomprog.dll.
3. In nxcomprog.cbl file you have created a method NEW, Is this method created using Class wizard then selecting Method Type as Factory or instance?
I actually didn't use the wizard to add the New method, I just added it directly to the source. You could add it using the wizard and it would be a factory method. If you are adding other methods then you should use the wizard so that it updated the interface definition automatically which makes the methods visible through COM.
4. in New method of nxcomprog.cbl, You have set the PP to entry "addprog" , Is addprog mentioned here is name of the native DLL or name of the starting program?
Yes, setting the pp data-item which is defined as a procedure-pointer to the entry of your .dll name causes it to load the .dll and make its entry points visible for calling. In this example the name of the native .dll is addprog.dll.
-----------------------------------
I believe that the error you are seeing is because you do not have the link options on the two .dlls set to be the same. They should both be set to multi-threaded and dynamic binding.
Hi
In our project earlier we were using a unmanaged DLL that was consumed by C . Now we are migrating from C to .NET. So the same DLL can not be consumed by .NET.
The problem statement:-
The COBOL program "Prog1" inside the DLL is having 4 Entry points.
As read from some of the threads we are trying to create a COBOL COM wrapper Class from File -> New->CLASS->COM Component.
This will create a new class in a new Net Express project. then We tried to create 4 method using Class wizard in this Class for all entry points.
1. Like Method1 for Entry1
2. Method2 for Entry2.
Now we are not able to understand how to make a call to existing (Prog1) COBOL program for an entry points in the Method.
We also tried the below option:
Method 1()
:declare in local storage of method 1
77 default-entry-point procedure-pointer.
:Code in Mehtod
set Default-Entry-point to entry "Prog1". (in an method1)
and then call the Entry point.
Call "Entry1" using
After this we compiled and build the Code and an DLL is created.
That DLL is registered using REGSVR32 and TILBIMP is doen for the same at .NET side.
Now when .NET tried to call MEthod1 after creating object of the Net Express Class.
We are getting an error 173 Called program not found in drive/directory.
Let us know where we are making mistake.
Thanks
Charan
Chris
Thanks a lot for your help. We were able to call and execute the modules from Native DLL. But we need to change the Build settings of existing native DLL. This will require some additional testing to be done for other programs present in Native DLL :-)
Thanks a lot for your help, Appreciated your help for the same.
Thanks
Charan