2

I had a working .net dll exposed as a com object using the non unicode version of inno. It has been working for a long time and has not had any changes. I am trying to convert to the unicode version of inno, and ran into an issue where calling CreateOleObject now throws "The parameter is incorrect, ProgId: ***"

To recreate this issue...

Create a C# project named samplecom and mark the assembly as COM-Visible in the project properties/Assembly Information

Use the following code in the default Class1.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace samplecom
{
    [ComVisible(true)]
    public class MyClass
    {
        [ComVisible(true)]
        public string MyMethod()
        {
            return "Hello from COM dll";
        }
    }
}

Build the project and then from a DOS/command prompt as Administrator register the dll using RegAsm, Note: the following assumes you are in the same directory as the dll or the samplecom\bin\debug folder

c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe samplecom.dll /tlb:samplecom.tlb /codebase

Then using the following script test using but the non unicode and unicode versions of inno

[Setup]
AppName=My Sample COM
AppVersion=1.0
DefaultDirName={pf}\samplecom

[Code]
Var
  comObject: Variant;

function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
begin
  if CurPage = wpWelcome then begin
    comObject := CreateOleObject('samplecom.MyClass');

    log(comObject.MyMethod());
  end;
  Result := True;
end;

Here is output of ansi version of inno

[15:50:23.779]   *** Setup started
[15:50:25.435]   Setup version: Inno Setup version 5.5.8 (a)
[15:50:25.437]   Original Setup EXE: C:\dev\innosandbox\Output\setup.exe
[15:50:25.439]   Setup command line: /SL5="$82622,56832,56832,C:\dev\innosandbox\Output\setup.exe" /SPAWNWND=$92602 /NOTIFYWND=$1A2580 /DEBUGWND=$5310D8 
[15:50:25.440]   Windows version: 10.0.14393  (NT platform: Yes)
[15:50:25.441]   64-bit Windows: Yes
[15:50:25.443]   Processor architecture: x64
[15:50:25.445]   User privileges: Administrative
[15:50:25.446]   64-bit install mode: No
[15:50:25.450]   Created temporary directory: C:\Users\Keith\AppData\Local\Temp\is-E13L9.tmp
[15:50:35.234]   Hello from COM dll

Update: 3/9/2017

Here is a link to the project along with a copy of the inno script.

https://www.dropbox.com/s/nxkwtgm086dtokv/InnoCom.zip?dl=0

I am not sure if it is related or a different issue, but using vbscript/cscript I am able to load the COM object using 32bit vbscript/cscript but it fails to load using the 64bit vbscript/cscript

The test.vbs file

Dim objXL
Set objXL = WScript.CreateObject("InnoCom.Inno")

2 Answers2

1

Inno Setup's v6.0.3(u) help gives the answer. Under "Pascal Scripting: Using COM Automation objects", the line just above "IUnknown based COM" the text reads:

If you're using a .NET COM object and loading it fails since Inno Setup 5.5.9 try putting this line in your script before creating the COM object: LoadDLL(ExpandConstant('{sys}\mscoree.dll'), ErrorCode); and add a variable ErrorCode of type Integer.

For me it solved the issue mentioned above.

See https://www.jrsoftware.org/ishelp/topic_scriptautomation.htm

0

Try isetup-5.5.8-unicode.exe version from official site (http://files.jrsoftware.org/is/5/). My .net dll works great with version 5.5.8 when I use CreateOleObject and don't work with version 5.5.9 and higher. Also see the Revision History http://www.jrsoftware.org/files/is5.5-whatsnew.htm . Maybe you will find a solution for later versions.

5.5.9 (2016-04-06)

  • To further help protect installers against potential DLL preloading attacks, Setup/Uninstall now calls SetDefaultDllDirectories if available to remove the application directory from the DLL search order. If SetDefaultDllDirectories is not available or cannot be called, it now additionally preloads a set of system DLLs known to be loaded unsafely by older or unpatched versions of Windows.
  • Change in default behavior: the OutputBaseFileName [Setup] section directive now defaults to mysetup instead of setup. Setting it back to setup is not recommended: all executables named "setup.exe" are shimmed by Windows application compatibility to load additional DLLs, such as version.dll. These DLLs are loaded unsafely by Windows and can be hijacked. If you do so anyway, the compiler will issue a warning.
  • Added new [Files] section flags: sign and signonce. Instructs the compiler to digitally sign the original source files before storing them. Ignored if [Setup] section directive SignTool is not set. Inno Setup's own compiler files are now also signed.
  • [Setup] section directive LZMADictionarySize now allows the LZMA dictionary size to be increased up to 1 GB from the previous maximum of 256 MB. Review the memory requirements listed in the Compression topic before using!
  • Improved the "auto-retry" feature of the [Files] section: it now also retries if MoveFile failed even if the preceding DeleteFile succeeded. Additionally, if MoveFile keeps failing it will now register the file to be replaced on restart if the restartreplace [Files] section flag is used instead of displaying an error message.
  • The value of the AppVersion directive is now not only used to set the MajorVersion and MinorVersion values in the Uninstall registry key when possible but also used to set the VersionMajor and VersionMinor values as required by newer versions of the Windows App Certification Kit.
  • Inno Setup Preprocessor (ISPP) changes:

  • Added new function RemoveFileExt.
  • Documented predefined variable ISPPCC_INVOKED.
  • Console-mode compiler (ISCC) change: Added new command line parameter /J. Can be used to #include additional files.
  • Unicode Inno Setup: Added official Armenian translation.
  • Minor tweaks.
  • bublik
    • 11
    • 2
    • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](https://meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted](https://stackoverflow.com/help/deleted-answers). – brass monkey Aug 23 '18 at 15:36