R
R
ralexen2022-04-14 18:00:23
Delphi
ralexen, 2022-04-14 18:00:23

Why doesn't a dll created in C++Builder 10.3 when dynamically loaded into an exe created in VisualStudio 19 execute the DllMain code?

The dll is written and compiled in C++Builder 10.3 and includes Indy 10 objects. Indy 10 is written in Delphi and contains an initialization section that creates a CriticalSection. During dynamic loading in an exe created in C++ Builder, the dll initialization proceeds correctly: the code in the initialization section is executed, and a CriticalSection object is created accordingly. The code in DllMain is also executed.
If you dynamically load the same dll into an exe created in Visual Studio 19, then the code in the initialization section is not executed. That when referring to an uncreated CriticalSection object in the following code, it calls AV. The code in DllMain is also not executed.
_libmain, which is automatically created by C++ Builder in dll, has been replaced with DllMain. The result is the same: exe from C++ Builder enters it, but exe from VS does not. What can you recommend?
Addition: if you create a simple console application project in VS from scratch and dynamically connect the dll, then all sections of the initialization of the dll are executed correctly. In the VS project on which the question is asked, the exe loads the plugin, and the plugin already loads the dll. Maybe the problem is somewhere in the VS project settings?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hemul GM, 2022-04-14
@HemulGM

Debug the library in VS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question