I’m having issues importing a Delphi native dll to .net.
I’m getting System.EntryPointNotFoundException.
Here’s my delphi dll:
procedure ProcedimientoEncriptar(texto,clave,resultado:PChar); export stdcall;
var ...
begin
....
....
end;
exports
ProcedimientoEncriptar ;
And here’s my DllImport on .Net (C#) code:
[DllImport("CryptoDLL.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
public static extern void ProcedimientoEncriptar([MarshalAs(UnmanagedType.LPStr)]string texto, [MarshalAs(UnmanagedType.LPStr)]string clave, [MarshalAs(UnmanagedType.LPStr)] StringBuilder resultado);
Any help would be appreciated,
Diego.
The only explanation for
System.EntryPointNotFoundExceptionis that the DLL that the C# code is finding is not the DLL produced from the Delphi code that you show. So, perhaps the C# code is picking up an out of date version of the DLL. Or perhaps it’s picking up a completely different DLL.For example, my system has a DLL named
cryptdll.dllin the system32 directory. Most likely that’s the DLL that your C# code is finding.In order to make sure that the right DLL is found, you need to place a copy of the Delphi DLL in the same directory as the C# executable file.