Problem:
Is it possible to link to existing btrieve module in net Express with .Net?
Resolution:
Making calls to the Btrieve entry point "_BTRV" cannot be done directly from a .NET managed code program because the Windows 32-bit Btrieve library WBTRV32.DLL is, itself, an unmanaged Windows .DLL.
In order for a .NET COBOL program to call an unmanaged .DLL, it must use the PInvoke functionality. In this case, you cannot use the _btrv.gnt file as only Windows .DLLs can be added as references to a .NET project.
Use the following steps:
1. In the Net Express\\base\\lib directory their is a file called _btrv.obj.
Create a Net Express 4.0 project which packages this file as MFBTRV.dll (or any name) and under Link options the entry point name should be "_BTRV".
2. In your .NET project, right click on the References folder and select "Add Reference". Use the Browse button to navigate to the MFBTRV.dll and then select this and then press OK to Add the file as a reference in the project.
3. In the .NET COBOL program you will have to add an underscore in front of the CALL "BTRV" so it looks like "_BTRV".
4. The .NET compiler will see the CALL "_BTRV" and it will search through all the .dlls in the References folder to find the .dll containing this entry point. The .NET compiler will automatically generate the PInvoke code necessary to call this unmanaged .DLL.
4. In order to run the program, the MFBTRV.DLL and the WBTRV32.DLL would need to reside in a directory on the systems path.