From: David E. <de...@us...> - 2011-04-21 19:35:28
|
There are two ways to incorporate TC code with .NET. One is to use managed code by wrapping the OC C code, and run-time, into a COM object. The other is to call TC modules (DLL) directly as unmanaged code. While more risky, the second approach offers the ability to leverage the legacy code business logic, and add a winGUI interface. The following simple examples are presented as a proof of concept only. The sources were tested using Mono v2 (Linux-32) and CSharp v2 / Mingw (winXP-32). To build extract 'readme.txt' file, and follow instructions. Example: mono: >make htcobol -v -m cobshlib06.cob -o libcobshlib06.so gmcs /debug /out:program03.exe program03.cs ... >mono program03.exe program03: cobfunc_dll called ----------------------------- cobfunc_dll: enter an_int=42 count_int=10: 0 1 2 3 4 5 6 7 8 9 cobfunc_dll: exit ----------------------------- program03: cobfunc_dll return Return Value: 84 str: String filled in DLL In CSharp, most types are allocated dynamically. And since COBOL has limited pointer manipulation, some issues wiere encountered with C structures with dynamic memory allocation. Cheers, References: 1) Calling a DLL with C# (C Sharp) http://www.adp-gmbh.ch/csharp/call_dll.html |