0

I'm trying to call a C# function from Inno Setup, however I'm getting the error

Internal error: extracttemporyfile the file "ClassLibrary1.dll" was not found`

I have placed the .dll file in the same folder as the inno setup script and even tried adding the .dll to the [files] section like this

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

However I still get the same error as above.

Here in my C# code including the namespace (this is just to test if the function can be called)

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

namespace ClassLibrary1
{
   public class ActivationClass
   {
      [DllExport("Activation", CallingConvention.StdCall)]
      public static Boolean Activation([MarshalAs(UnmanagedType.BStr)] string input)
      {
        if (input == "1a2b3c")
        {
            return true;
        }
        return false;
      }
   }
}

Here is the Inno Setup Script

[Code]
function Activation(key: WideString): Boolean;
external 'Activation@files:ClassLibrary1.dll stdcall';

function InitializeSetup(): Boolean;
var status: Boolean;
begin
status := Activation('1a2b3c');
   case status of
   true: msgbox('true', mbInformation, MB_OK);
   false: msgbox('false',mbInformation, MB_OK);
   end;
Result := status; 
end;
user1234433222
  • 976
  • 2
  • 10
  • 21
  • unfortunately that's all its giving me, the code compiles, normally it wouldn't if it cant see the file I believe, so I'm a little confused as to why it wont access it – user1234433222 Jun 04 '18 at 12:18
  • 1
    I cannot reproduce your problem. Everything works just fine for me with your code. We need [mcve]. Make sure you copy paste *exact* code, as this looks like you have a typo somewhere. At least the error message was obviously typed by hand, not copied, as the literal error message is different. – Martin Prikryl Jun 04 '18 at 12:59
  • What is exactly, how it looks? The exact error message would be `ExtractTemporaryFile: The file "ClassLibrary1.dll" was not found` + I do not understand what you mean by *"how are you storing the dll"*. – Martin Prikryl Jun 04 '18 at 13:02
  • the code I have posted is exactly how it looks in my ides, how are you storing the file, i mean, how are you putting it to? in the same folder as the script? – user1234433222 Jun 04 '18 at 13:04
  • Yes, otherwise `Source: "ClassLibrary1.dll"` would not work. – Martin Prikryl Jun 04 '18 at 13:04
  • `DllExport` is not for COM. – Martin Prikryl Jun 04 '18 at 13:05
  • @MartinPrikryl yeah Ok, that's how i have it too, weird. – user1234433222 Jun 04 '18 at 13:05
  • Can you compile a simple installer that shows the problem and upload it somewhere? – Martin Prikryl Jun 04 '18 at 13:05
  • I just added the `[Files]` section back to see if it would make a difference again, at least now im getting a different error `cannot import dll: ClassLibaray.dll` I changed my C# build to x86, however the error is the same as mentioned – user1234433222 Jun 04 '18 at 13:09
  • 1
    Of course, you need the `[Files]` section entry. I assumed that you have it there. + You need the `x86` + `ClassLibaray.dll` - again that looks like a typo. - Anyway, you now have a completely different question, so it's time to edit your question and cleanup the comments. – Martin Prikryl Jun 04 '18 at 13:12
  • yeah I thought by having 'Activation@files:ClassLibrary1.dll stdcall'; that it would call it automatically without having to add the dll to the file section. – user1234433222 Jun 04 '18 at 13:13

0 Answers0