Delphi5 procedure call in C # dll

I have a big problem. I have a delphi5 application that calls C # dll. I want to call a function from my C # dll that needs a pointer to the delphi procedure as an input parameter. In this C # function, the delphi procedure is called afterwards.

I tried declaring a pointer to the C # side using IntPtr:

ourFunction(IntPtr fct){
   ...
   helpFct = (OurType)Marshal.GetDelegateForFunctionPointer(fct, typeof(OurType));
   ...
}

If I call a function from C #, everything works fine. But if I want to call it from Delphi (with the delphi procedure as an input parameter), it crashes without giving me any error information.

here is my delphi code:

hBuffer : THandle;
buffer : PInteger;
...
hBuffer:=GlobalAlloc(GMEM_fixed,SizeOf(Integer));
buffer:=GlobalLock(hBuffer);
buffer := Addr(AddDelphi);
intfRef.ourFunction(buffer^);

Does anyone have any experience with such problems or any ideas how this might work?

thanks Stefan

+3
source share
2 answers

Delphi 5, pre.NET. regasm # COM- Delphi 5., .

, , COM-.

+2

, Delphi 5, .NET-, # Delphi, RemObjects Hydra (Hydra : Delphi .NET).

, .NET Delphi .

, Delphi DLL P/Invoke #/.NET . .NET DLL Delphi .NET - .

, .NET Delphi JCL TJclClrHost (. SO, ).

-

0

All Articles