Forum > General

Error When Using imported Procedures

(1/1)

d2010:
I try compile the Hanoi_r.pas inside Lazarus.
The code is code my I cannot import mydll.dll
Mydll.dll was develope..............
One details mydll.dll is wad compiled {x86platform target}


--- Code: ---Procedure MyPrintPascal; external 'mydll.dll';
begin
 argc[1]:=0;
MyPrintPascal()?

--- End code ---

My Fix1== I try execute upx.exe  on my dll

--- Code: ---D:\...0win\coimport\Dlllist-of-imports>upx mydll.dll >>2
upx: mydll.dll: CantPackException: .NET files (win32/net) are not yet supported

--- End code ---


Remy Lebeau:

--- Quote from: d2010 on September 05, 2024, 09:14:26 pm ---My Fix1== I try execute upx.exe  on my dll

--- Code: ---D:\...0win\coimport\Dlllist-of-imports>upx mydll.dll >>2
upx: mydll.dll: CantPackException: .NET files (win32/net) are not yet supported

--- End code ---

--- End quote ---

So you have a DLL that was compiled in DotNET?  Did you confirm that the DLL actually exports the desired function?  Is the DLL using something like UnmanagedExports to export a managed .NET function in a way that unmanaged languages like Pascal can call it?

d2010:

--- Quote from: Remy Lebeau on September 05, 2024, 09:19:49 pm ---So you have a DLL that was compiled in DotNET?  Did you confirm that the DLL actually exports the desired function?  Is the DLL using something like UnmanagedExports to export a managed .NET function in a way that unmanaged languages like Pascal can call it?

--- End quote ---

Sorry my internet lucks, was blocked..
Other test for lazarus + dot C#net..
You try these code -lines bellow.

--- Code: ---
Procedure _CorDllMain ; external 'mscoree.dll';
Var msg:string;
Begin
   msg:='Here code/source is Lazarus.units';
   Try  _CorDllMain
Exceptton
    writeln('Error10=Lazarus cannot  load mscoree.dll');
    wrtieln('Error11=Even ; mydll was compiled with {x86targeting} and {not dot.net}')
End;

End.

--- End code ---

Remy Lebeau:

--- Quote from: d2010 on September 05, 2024, 09:29:26 pm ---
--- Code: ---Procedure _CorDllMain ; external 'mscoree.dll';

--- End code ---

--- End quote ---

That is not the correct signature for _CorDllMain, see:
https://learn.microsoft.com/en-us/dotnet/framework/unmanaged-api/hosting/cordllmain-function

It should be:


--- Code: ---uses
  Windows;

function _CorDllMain(hInst: HINSTANCE; dwReason: DWORD; lpReserved: Pointer): BOOL; stdcall; external 'mscoree.dll';

--- End code ---

Navigation

[0] Message Index

Go to full version