MSI安装被自定义操作DLL中断

MSI installation interrupted by custom action DLL

本文关键字:DLL 中断 操作 自定义 安装 MSI      更新时间:2023-10-16

我已经使用了一个Visual Studio设置项目来创建MSI。我已经在ORCA中编辑了MSI,以便在首次打开时通过DLL执行自定义操作。当我运行MSI时,msiexec记录以下内容:

MSI (c) (E4:BC) [15:28:14:453]: Doing action: CustomAction1
Action 15:28:14: CustomAction1. 
Action start 15:28:14: CustomAction1.
MSI (c) (E4:BC) [15:28:14:453]: Note: 1: 2235 2:  3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'CustomAction1' 
MSI (c) (E4:BC) [15:28:14:453]: Creating MSIHANDLE (13) of type 790542 for thread 3260
MSI (c) (E4:B4) [15:28:14:453]: Invoking remote custom action. DLL: C:DOCUME~1USERNA~1LOCALS~1TempMSIA3.tmp, Entrypoint: SampleFunction
MSI (c) (E4:B4) [15:28:14:453]: Closing MSIHANDLE (13) of type 790542 for thread 3260
Action ended 15:28:14: CustomAction1. Return value 3.
MSI (c) (E4:BC) [15:28:14:468]: Doing action: FatalErrorForm
Action 15:28:14: FatalErrorForm. 
Action start 15:28:14: FatalErrorForm.
MSI (c) (E4:BC) [15:28:14:468]: Note: 1: 2235 2:  3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'FatalErrorForm' 

安装程序向导然后显示错误消息:The installer was interrupted before MyProduct could be installed. You need to restart the installer to try again.

自定义DLL用C 编写。这是源代码:

mycustomation.cpp:

// MyCustomAction.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}
UINT __stdcall SampleFunction(MSIHANDLE hModule)
{
        //This is the function that is called by the MSI
        //It is empty because I just want to check that it can be called without interrupting the installer, then I will add the actual functionality
}

mycustomation.def:

; MyCustomAction.def
;
; defines the exported functions which will be available to the MSI engine
LIBRARY      "MyCustomAction" 
DESCRIPTION  'Custom Action DLL'
EXPORTS
    SampleFunction

我还在DLL的其他依赖项中引用了msi.lib。当我目前没有明确告诉它做任何事情时,为什么自定义操作中断安装?任何帮助将不胜感激。

更新:

在ORCA中,自定义操作在Binary表中,并且在CustomAction表中是类型1。自定义操作是Immediate,在IsolateComponents之后和在InstallUISequence表中进行WelcomeForm之前进行。

您应该更新代码和帖子,以表明您实际上返回了error_success。无论是否解决问题,重点是要做的是正确的事情。如果不返回值,则调用序列将失败并获取错误。

由于缺失的依赖关系,您的DLL可能不会加载。如果您在代码中放置一个简单的消息框调用,则至少会查看代码是否实际运行。C 将需要可能还没有系统上的运行时支持DLL。

事实证明您对C 运行时间有依赖性,则在运行MSI之前需要安装它们。这就是先决条件选择的目的 - 它生成一个设置。EXE安装依赖项然后安装您的MSI。