1
  • Inno Setup version 5.6.1(u).

  • Dev Studio 2015 64 bit class library.

  • .NET Framework 4.6.1

  • Uses the UnamanagedExports package.

Here's the script:

[Setup]
ArchitecturesInstallIn64BitMode=x64
ArchitecturesAllowed=x64

[Files]
Source: "DotNet64.dll"; Flags: dontcopy

[Code]
function TestFunction(): Boolean;
external 'Testing@files:DotNet64.dll stdcall setuponly delayload'; 

procedure CurPageChanged(CurPageID: Integer);
var
  ires : Boolean;
begin
  if CurPageID = wpWelcome then begin
    ires := TestFunction();
  end;
end;

Here's the C# DLL code

using RGiesecke.DllExport;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace DotNet64
{
    public class InnSetDLL
    {
      [DllExport("Testing", CallingConvention = CallingConvention.StdCall)]
      public static bool Testing()
      {
         return false;
      }
   }
}

As soon TestFunction() is called in the script, I get a popup:

Runtime Error (at 2:55): Could not call proc.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Jana Andropov
  • 121
  • 11

1 Answers1

2

Is the DotNet64.dll compiled as a 64 bit DLL? InnoSetup can't access 64 bit DLLs as per the documentation. You can compile it as a 32 bit DLL or write a 64 bit EXE that calls your 64 bit DLL and execute the 64 bit EXE.

mirtheil
  • 8,952
  • 1
  • 30
  • 29
  • Indeed. Just set *Platform target* of your project to *x86* - See [Calling .NET DLL in Inno Setup](https://stackoverflow.com/q/8487925/850848#42711143). – Martin Prikryl Dec 01 '18 at 07:55