aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

MSI upgrade failing on .net installer custom action

Tue Aug 24, 2021 8:05 pm

We are testing an upgrade to our product...this is not the first, and this is not the first time we've used this custom action - it has not been changed, and it previously worked correctly for installs and upgrades. We are using AI 18.5 Professional on Win10 x64.

Specifically we are calling a "NetInstallerClass_Install" to perform some parts of the install environment config and other custom checks.

Testing our new package, an initial/full install (no upgrade) works great - this custom action works fine, as does a following one (a "Commit").

However, during an upgrade (uninstall previous version first), this class/method apparently can not be found in the assembly? (Same assembly)

I see this in the log:

Code: Select all

MSI (s) (A8:F0) [13:49:59:792]: Executing op: ActionStart(Name=NetInstallerClass_x64_Install,Description=Preparing Files and Registry,)
MSI (s) (A8:F0) [13:49:59:794]: Executing op: CustomActionSchedule(Action=NetInstallerClass_x64_Install,ActionType=1025,Source=BinaryData,Target=LaunchDotNetCustomAction,CustomActionData=/LogFile="C:\Users\BORT\AppData\Local\Temp\EveryDoc_install.log" /ReqVersion=4.0.30319 /InstallType=notransaction /Action=Install /IsUpgrade="{C82CB7D9-2E8F-4CA0-A9E5-D72126B82938}" /UrlUpdateInfo="http://amrvwp000001128:4056" /AppDir="C:\Users\BORT\AppData\Local\Programs\EveryDoc\\" /COUninstallExe="C:\Users\BORT\AppData\Local\Temp\ClickOnceUninstaller.exe" /AddInName="SafeName.AddinModule" "C:\Users\BORT\AppData\Local\Programs\EveryDoc\SafeName.dll" "C:\Users\BORT\AppData\Local\Temp\NetInstallerClass_Config.xml")
MSI (s) (A8:E4) [13:49:59:800]: Invoking remote custom action. DLL: C:\windows\Installer\MSI2477.tmp, Entrypoint: LaunchDotNetCustomAction
MSI (s) (A8:30) [13:49:59:800]: Generating random cookie.
MSI (s) (A8:30) [13:49:59:811]: Created Custom Action Server with PID 10400 (0x28A0).
MSI (s) (A8:3C) [13:49:59:899]: Running as a service.
MSI (s) (A8:3C) [13:49:59:913]: Hello, I'm your 64bit Impersonated custom action server.
MSI (s) (A8!80) [13:52:11:563]: 
MSI (s) (A8:E4) [13:52:11:573]: Leaked MSIHANDLE (222) of type 790531 for thread 12416
MSI (s) (A8:E4) [13:52:11:573]: Note: 1: 2769 2: NetInstallerClass_x64_Install 3: 1 
Info 2769. Custom Action NetInstallerClass_x64_Install did not close 1 MSIHANDLEs.
CustomAction NetInstallerClass_x64_Install returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 13:52:11: InstallExecute. Return value 3.
Our custom log shows this:

Code: Select all

An exception occurred while trying to find the installers in the C:\Users\BORT\AppData\Local\Programs\EveryDoc\SafeName.dll assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Aborting installation for C:\Users\BORT\AppData\Local\Programs\EveryDoc\SafeName.dll.
I do not know if it's relevant, but while that installer-class was NOT edited in the past few versions of our software, this new package's project was bumped to .Net 4.6.2. So IDK if the installer's "custom action server" is using the wrong .Net version during an upgrade (it's continuing to use whatever the version was for the product being uninstalled)?

Can someone please help us troubleshoot this issue ASAP? We are trying to release the product on a deadline.

aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: MSI upgrade failing on .net installer custom action

Tue Aug 24, 2021 8:30 pm

As a test, and realizing that it was never set, I updated the "ReqVersion" property of all my NetInstallerClass custom actions to value = "4.6.2".

The upgrade failed the same way according to the log, the message on the dialog was Error 1001. InstallUtil.Lib.dll: Unknown Error.

Actually, now all installs (even new installs) fail with this error. How is this possible that this custom action was working and I did not change it or the .Net class and now it fails? (To troubleshoot I updated the ReqVersion just now, and apparently that made it worse.)

Maybe that helps. IDK what to do.

Thanks.

EDIT/UPDATE: Reverted by re-selecting the dll in the custom action and AI re-populated the ReqVersoin to 4.0.xxxx. Back to the scenario in the OP...upgrades fail, new installs work. Not sure how the same exact class and method can be found when AI launches it for a new install and not found when launching it for an upgrade.

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: MSI upgrade failing on .net installer custom action

Wed Aug 25, 2021 9:59 am

Hello,

This is quite strange. Unfortunately, I can not really say why this is happening.

Regarding the error “Error 1001. InstallUtil.Lib.dll: Unknown Error.” message can you try the solution exposed on Why do I receive the "Error 1001.InstallUtilLib.dll" error? FAQ
and see if that helps you?

Otherwise, can you please send us by email to support at advancedinstaller dot com so we can further test and investigate this, the following files:
  1. the .AIP (setup project) file
  2. an installation log of the the upgrade process when the custom action fails.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: MSI upgrade failing on .net installer custom action

Wed Aug 25, 2021 3:30 pm

Hi,

I checked the sample project you sent us via email.

The custom action that fails may need administrative privileges so in this case you should have the "Run under the LocalSystem account with full privileges (no impersonation)" option enabled from the "Execution Options" section.
customAction.jpg
customAction.jpg (83.96KiB)Viewed 26857 times

Can you try the above option and tell us if this helps?

Also, I noticed in your project that you have a pre-install prerequisite on an .MSI build package.
The "Pre-install Prerequisites" can only be installed by the EXE Bootstrapper. They are included in the EXE Bootstrapper and installed before the MSI is launched.
"Pre-install Prerequisites" are not supported by the MSI.

If you try to add the “.NET Framework” as a "Feature-based Prerequisite", that won’t work. On our Why does .NET Framework fails as a feature-based prerequisite? FAQ you can find why. .NET Framework can be installed only as a pre-install prerequisite which requires the EXE Bootstrapper.

Please let us know if there is anything else we could help you with.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: MSI upgrade failing on .net installer custom action

Wed Aug 25, 2021 3:56 pm

OK, please help me understand your logic...

The install package (MSI) works perfectly if it is NOT an upgrade. Why would changing the Run under LocalSystem option affect only the upgrade path? The installer appears to not find the requested class during an upgrade - it's not that it can't run it...it says it's not found. I am very hesitant to require the end-user to have additional rights over that which is absolutely necessary for install...it's standard least-privs security best practices.

Also, this exact same installer class has been functioning fine for new installs and upgrades prior to this AI-build (latest, previous build was with AI 18.1). Why would this have changed? The only difference is that we are building with AI 18.5 now.

On your (unrelated, but helpful) point about .Net prerequisites, you are saying that AI can not enforce a .Net framework during pre-install (either decline to install or prompt to install the requested framework) with an MSI installer? It is also identified in "Launch Conditions".

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: MSI upgrade failing on .net installer custom action

Thu Aug 26, 2021 9:16 am

Hi,
EDIT/UPDATE: Reverted by re-selecting the dll in the custom action and AI re-populated the ReqVersoin to 4.0.xxxx. Back to the scenario in the OP...upgrades fail, new installs work. Not sure how the same exact class and method can be found when AI launches it for a new install and not found when launching it for an upgrade.
It's not very clear for me if you tried the above solution I gave you about the "Error 1001. InstallUtil.Lib.dll: Unknown Error" error. This error is shown when installing a package that includes a merge module which contains a .NET assembly with an Installer Class.

Can you set back the "ReqVersion" property of the custom action to value "4.6.2" and follow these steps:
  1. add a temporary .XML file named "config.xml" with the following content:

    Code: Select all

    <?xml version="1.0"?>
    <configuration>
     <startup>
      <supportedRuntime version="v1.1.4322"/>
      <supportedRuntime version="v1.0.3705"/>
      <supportedRuntime version="v2.0.50727"/>
      <supportedRuntime version="v4.0.30319"/>
     </startup>
    </configuration>
  2. add a "Set installer property" custom action with sequence after "Preparing" action group:
    • Property: VSDFxConfigFile
    • Formatted: [&config.xml]
This solution is already detailed in our FAQ which I already sent you: Why do I receive the "Error 1001.InstallUtilLib.dll" error?

Can you tell us if this works?
On your (unrelated, but helpful) point about .Net prerequisites, you are saying that AI can not enforce a .Net framework during pre-install (either decline to install or prompt to install the requested framework) with an MSI installer?
Yes, the pre-install prerequisites can not be installed by the .MSI package. You can find more information on the Prerequisites page. The pre-install prerequisites will always be ignored if you build an .MSI package.
It is also identified in "Launch Conditions".
In the Launch Conditions view you can specify conditions that must be fulfilled in order for your application to install.
So if the target machine does not have the ".NET Framework 4.6.2", then the launch condition will be triggered thus the installation will fail. The launch condition prevents the setup from being installed on a machine where the requirements are not fulfilled.

For example, if I try to install your setup on a machine without Outlook 2010, the install fails with the following error:
launchCondition.png
launchCondition.png (15.42KiB)Viewed 26835 times
Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: MSI upgrade failing on .net installer custom action

Thu Aug 26, 2021 1:40 pm

When I say I reverted the ReqVersion, what I did was re-selected the DLL that contains the Installer Class (my primary binary/distributable) using the AI GUI. This auto-populated the ReqVersion back to 4.0.xxxx. Packaging that up results in the original behavior...there is no error on the InstallLib, just the original issue described in the original post. This is slightly better, because a new install succeeds, but upgrades fail.

AI is somehow not able to find/execute the class' methods on an upgrade - but it can do so on a new install perfectly. Since it is the exact same class and method being attempted, I find there must be an issue with AI 18.5. Please tell us how to troubleshoot further.

I have sent you an example log from a successful (new) install. You already have a sample log from an upgrade (failed). What is going on?

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: MSI upgrade failing on .net installer custom action

Fri Aug 27, 2021 9:28 am

Hi,

I'm afraid that we are not able to replicate the encountered behavior on our end.

To further investigate this, please strip down your project to a basic size containing only the resources absolutely necessary to reproduce the issue.
Make sure this sample project is buildable and send it so we can build it and study the issue.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: MSI upgrade failing on .net installer custom action

Fri Aug 27, 2021 2:12 pm

Can you please send me the project you are using to test - that is unable to replicate the issue - and I can test that in my environment as well?

Thank you.

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: MSI upgrade failing on .net installer custom action

Mon Aug 30, 2021 2:43 pm

Hello,

You can find the sample projects here.

There are 2 folders, v1 and v2, both containing the .msi setup, .aip file and the visual studio .NET installer project.
v1 .dll contains the “test v1” message box. After upgrading the project and the .dll versions, on install the “test v2” is shown as expected.

Can you test this on your machine and tell us if it works?

Otherwise, can you also send us your old .aip (setup project) file so we can compare its settings?

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: MSI upgrade failing on .net installer custom action

Mon Aug 30, 2021 8:52 pm

I can confirm that the simple project you sent does work as expected.

I am emailing you a previous version of our project (probably from 18.1).

Since the class library (and therefore class) is obviously present, the "Class not Found" makes no sense, unless it's looking for a dependency that is changing or something? Do you know how I can enable any more detailed debug logging so we can see the Loader's actions and what it's trying to do and therefore exactly where it's failing?

Thanks.

aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: MSI upgrade failing on .net installer custom action

Wed Sep 01, 2021 4:39 pm

Did you receive my v18.1 project and attempt to discern the differences from that? I'm still not clear as to why this new build works fine on install, but fails on upgrade. Since we are uninstalling the previous version first (per the AI package settings), shouldn't it behave the same at that point in the installer?

ALSO: I fully tested the workaround for the installerlib.dll problem (adding the custom xml file - though the formatted text does not seem to find that file in the gui). This does not help the problem.

In the Error 1001 message that appears to the user, it says to "Retrieve the LoaderExceptions property for more information." How do we get that property? Is that something we can set the AI "Custom Action Server" to do? If the class can't be loaded, I don't see how it can be done from within my code...it would have to be caught and the exception info output to the install log.

**** When the error occurs during upgrade, we left the message box on screen and used a Dependency Walker. There are at least 4 dependencies (dlls) missing from the install dir (APPDIR) at that time. These are all "MainFeature" files, for example all of the "System.Data.SQLite....dll" files are missing (you can check the project file I sent you). That probably explains why there is a loader-exception, because AI has not put all of the dependencies in the folder yet. BUT when a "New Install", they are all present!!! (And post-install they are still present, as expected and designed for this app.)

Why is AI not completing the installation/copying of the files before attempting to continue??? And why does this only happen on an Upgrade scenario, not on a New Install?

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: MSI upgrade failing on .net installer custom action

Thu Sep 02, 2021 2:52 pm

Hi Aaron,

Thank you for your information about the missing files. Based on your discovery I think I found what the problem is.

After the old package is detected, Windows Installer automatically determines which files will be installed based on the file versioning rules.

Since the files are already installed, the ones in the old package are compared to the ones in the new package. If a file included in the new package has a file version lower than the file version of its corresponding file from disk, then the file from the new package is no longer installed.

You can find more information on our Why some files/assemblies are missing from the installation folder when performing an upgrade? FAQ article.

To overcome this behavior, you can enable the “Always overwrite existing file” for the missing files. Just go to the “Files and Folders” page and right click on the file → PropertiesOperations tab and check the “Always overwrite existing file”.

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”