0

Can anyone shed light on this Inno Setup error that one of my users is getting?

enter image description here

He can install the same software on another computer with no issues. I asked him to supply me with his log file (the installer copies the log to a specific folder with a timestamp in the CurStepChange procedure (when the CurStep = ssDone).

But he could not find any log. I have now asked him to run the installer from a Command Prompt with the /log="..." switch to see if we can get at the log that way.

His computer is running Windows 11 (this is also my development PC operating system).

Any ideas?


Note that the installer does check for the existing of the Framework in the InitializeWizard procedure:

dotNetNeeded := not IsDotNetInstalled(net462, 0);
if (dotNetNeeded) then begin
    if (MsgBox(ExpandConstant('{cm:DotNet_NeedToDownload}'), \
                                        mbConfirmation, MB_OKCANCEL) = IDCANCEL) then begin
        Abort();
    end;
end;

Update

I am no Delphi developer, but I thought I would check the public source code for Inno Setup and I found two places where this error is displayed:

function GetDotNetInstallRoot(const RegView: TRegView): String;
var
  K: HKEY;
begin
  if DotNetRoot[RegView] = '' then begin
    if RegOpenKeyExView(RegView, HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework', 0, KEY_QUERY_VALUE, K) = ERROR_SUCCESS then begin
      RegQueryStringValue(K, 'InstallRoot', DotNetRoot[RegView]);
      RegCloseKey(K);
    end;
    if DotNetRoot[RegView] = '' then
      InternalError('.NET Framework not found');
  end;
  Result := DotNetRoot[RegView];
end;

function GetDotNetVersionInstallRoot(const RegView: TRegView; const Version: TDotNetBaseVersion): String;
const
  VersionStrings: array [TDotNetBaseVersion] of String = ('1.1', '2.0', '4.0', '');
var
  K: HKEY;
begin
  if DotNetVersionRoot[RegView, Version] = '' then begin
    GetDotNetInstallRoot(RegView);
    if (Version in [netbase40, netbaseHighestKnown]) and (RegOpenKeyExView(RegView, HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\Policy\v4.0', 0, KEY_QUERY_VALUE, K) = ERROR_SUCCESS) then begin
      DotNetVersionRoot[RegView, Version] := AddBackslash(DotNetRoot[RegView]) + 'v4.0.30319';
      RegCloseKey(K);
    end else if (Version in [netbase20, netbaseHighestKnown]) and (RegOpenKeyExView(RegView, HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\Policy\v2.0', 0, KEY_QUERY_VALUE, K) = ERROR_SUCCESS) then begin
      DotNetVersionRoot[RegView, Version] := AddBackslash(DotNetRoot[RegView]) + 'v2.0.50727';
      RegCloseKey(K);
    end else if (Version in [netbase11, netbaseHighestKnown]) and (RegOpenKeyExView(RegView, HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\Policy\v1.1', 0, KEY_QUERY_VALUE, K) = ERROR_SUCCESS) then begin
      DotNetVersionRoot[RegView, Version] := AddBackslash(DotNetRoot[RegView]) + 'v1.1.4322';
      RegCloseKey(K);
    end;
    if DotNetVersionRoot[RegView, Version] = '' then begin
      if Version <> netbaseHighestKnown then
        InternalError(Format('.NET Framework version %s not found', [VersionStrings[Version]]))
      else
        InternalError('.NET Framework not found');
    end;
  end;
  Result := DotNetVersionRoot[RegView, Version];
end;

That code is in the DotNet.pas file.


As a resut of the above location in Inno Setup raising the error, I have asked him to use regedit and verify the existing off:

\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319

Update

So he did try the install using the /log switch and as expected, it says:

2022-05-13 14:15:46.196   Fatal exception during installation process (Exception):
                          Internal error: .NET Framework not found.
2022-05-13 14:15:46.196   Exception message:
2022-05-13 14:15:46.196   Message box (OK):
                          Internal error: .NET Framework not found.
2022-05-13 14:15:53.456   User chose OK.
2022-05-13 14:15:53.456   Message box (OK):
                          Setup was not completed.
                          
                          Please correct the problem and run Setup again.
2022-05-13 14:15:59.450   User chose OK.
2022-05-13 14:15:59.450   Rolling back changes.
2022

I now await his response about the registry key.


I can confirm that in his case, whilst all the framework files etc are installed, that the cause of the internal failure is this function:

function GetDotNetInstallRoot(const RegView: TRegView): String;
var
  K: HKEY;
begin
  if DotNetRoot[RegView] = '' then begin
    if RegOpenKeyExView(RegView, HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework', 0, KEY_QUERY_VALUE, K) = ERROR_SUCCESS then begin
      RegQueryStringValue(K, 'InstallRoot', DotNetRoot[RegView]);
      RegCloseKey(K);
    end;
    if DotNetRoot[RegView] = '' then
      InternalError('.NET Framework not found');
  end;
  Result := DotNetRoot[RegView];
end;

Here does not have the InstallRoot registry value.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • 1
    The approach your script uses (`InstallRoot`) is long out of date. Microsoft documents the official way in https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed and shouldn't be that hard for you to translate to Pascal Script as you already get examples. – Lex Li May 13 '22 at 20:06
  • @LexLi That is not my script - that is the Inno Setup script (I linked to it - `DotNet.pas`). That is, it is part of Inno itself, not my own script or anything. – Andrew Truckle May 13 '22 at 20:23
  • 1
    Instead of relying on Inno Setup sample/built-in scripts, you can always write your own according to what Microsoft says in your own `InitializeSetup` function then. – Lex Li May 13 '22 at 20:27
  • @LexLi I get that. But all the same I am directing this ticket to Inno team too. – Andrew Truckle May 13 '22 at 20:28
  • https://stackoverflow.com/q/4104011/2287576 looks promising. Seems to be the right way to do it. Testing. – Andrew Truckle May 13 '22 at 20:41
  • Turns out that this particular issue is because my script is using the `{dotnet40}` and `{dotnet4064}` constants for using `regasm`. The user does not have the `InstallRoot` path in the registry. – Andrew Truckle May 14 '22 at 21:48
  • See: https://groups.google.com/g/innosetup/c/u3ty6tfi4Ek – Andrew Truckle May 14 '22 at 21:49

0 Answers0