Problems in .Net Compatibility with Borland C ++

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();//Application crashes here. } 

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.

+4
source share
1 answer

Error code 0xe0434352 is an exception to the CLR. When they arise at startup in my experience, they are always a problem when placing assemblies. You can enable assembly binding logs to help you find out what cannot be loaded. In any case, the .NET assembly must be in the .exe directory or registered in the GAC, if in a different place.

If this is not an error loading assemblies, try connecting the Windows debugger (windbg) and using its controlled debugging to see exactly what a .NET exception is.

+2
source

Source: https://habr.com/ru/post/1438568/


All Articles