I have a C # library that I want to use in Borland C ++. The approach I used was to use mixed-mode libraries, i.e. use C ++ / CLI as an intermediate element between the C # library and Borland C ++. I created a sample HelloWorld program
C # library:
namespace Hello { class HelloWorld { public void Display(); { Console.WriteLine("Hello World"); } } }
C ++ / CLI:
I created an empty VC ++ project and added a C # library as a reference to a C ++ / CLI project that exports a single function. I changed the project settings to use / clr and changed the application type to DLL.
test.h
__declspec(dllexport) void DisplayHello();
test.cpp
#include "Test.h" using namespace Hello; __declspec(dllexport) void DisplayHello() { HelloWorld ^ mHello = gcnew HelloWorld(); mHello->Display(); }
Borland C ++:
I took the DLL generated by Visual Studio and used the IMPLIB utility provided by Borland to create a LIB file that the Borland C ++ compiler understands.
I use the generated lib file and the Test.h header file to create a BCB project, I have a function that calls DisplayHello
void CallDisplay() { DisplayHello();
Itβs strange that I noticed that when I delete
HelloWorld ^ mHello = gcnew HelloWorld(); mHello->Display();
the program is working fine.
It throws an EExternal Exception "e0434352". There seems to be some problems in the way I use HelloWorld, I canβt determine what could crash, any help would be appreciated.
source share