Recent

Author Topic: Error When Using imported Procedures  (Read 442 times)

d2010

  • Jr. Member
  • **
  • Posts: 52
Error When Using imported Procedures
« on: September 05, 2024, 09:14:26 pm »
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: [Select]
Procedure MyPrintPascal; external 'mydll.dll';
begin
 argc[1]:=0;
MyPrintPascal()?

My Fix1== I try execute upx.exe  on my dll
Code: [Select]
D:\...0win\coimport\Dlllist-of-imports>upx mydll.dll >>2
upx: mydll.dll: CantPackException: .NET files (win32/net) are not yet supported


« Last Edit: September 05, 2024, 09:21:46 pm by d2010 »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1408
    • Lebeau Software
Re: Error When Using imported Procedures
« Reply #1 on: September 05, 2024, 09:19:49 pm »
My Fix1== I try execute upx.exe  on my dll
Code: [Select]
D:\...0win\coimport\Dlllist-of-imports>upx mydll.dll >>2
upx: mydll.dll: CantPackException: .NET files (win32/net) are not yet supported

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?
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

d2010

  • Jr. Member
  • **
  • Posts: 52
Re: Error When Using imported Procedures
« Reply #2 on: September 05, 2024, 09:29:26 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?

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

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.
« Last Edit: September 05, 2024, 09:31:23 pm by d2010 »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1408
    • Lebeau Software
Re: Error When Using imported Procedures
« Reply #3 on: September 05, 2024, 09:39:44 pm »
Code: [Select]
Procedure _CorDllMain ; external 'mscoree.dll';

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: [Select]
uses
  Windows;

function _CorDllMain(hInst: HINSTANCE; dwReason: DWORD; lpReserved: Pointer): BOOL; stdcall; external 'mscoree.dll';
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018