使用Visual Studio 2008自定义安装程序时出现1001错误

8
我创建了一个简单的WinForms应用程序和一个自定义安装程序。所有这些似乎都很简单,但是在事件日志中我收到了以下弹出窗口和错误详细信息。

Error message box displayed before running the custom action code

源自MsiInstaller的事件ID 11001的描述未找到。引发此事件的组件可能未安装在本地计算机上,或者安装已损坏。您可以在本地计算机上安装或修复组件。
如果事件源自另一台计算机,则必须使用事件保存显示信息。
事件包括以下信息:
产品:Custom Action Tester -- Error 1001. Error 1001. 在初始化安装时发生异常: System.IO.FileNotFoundException:无法加载文件或程序集“file:///C:\Windows\system32\Action”或其某个依赖项。系统找不到指定的文件。(NULL) (NULL) (NULL) (NULL)(NULL)
消息资源存在,但在字符串/消息表中找不到该消息。
我已检查了C:\Windows\system32,没有名为Action的文件或文件夹,但有3个文件:ActionCenter.dll,ActionCenterCPL.dll和ActionQueue.dll.
有什么解决此错误的想法吗?
编辑:

cosmin-pirvu的建议下,我使用日志运行了安装程序。出现错误的区域如下所示,但我仍然不知道如何解决这个问题。

MSI (s) (40:7C) [09:34:26:523]: Executing op: CustomActionSchedule(Action=_FBC0CC84_D5B4_41F9_A3EC_98A13BC7E73E.install,ActionType=3073,Source=BinaryData,Target=ManagedInstall,CustomActionData=/installtype=notransaction /action=install /LogFile= /targetdir="C:\Test\Custom Action Tester\" /Param1="C:\Test\TestFile.txt" /Param2="C:\Test\" "C:\Test\Custom Action Tester\ConfigSetup.dll" "C:\Users\wildb\AppData\Local\Temp\CFG66BE.tmp")
MSI (s) (40:94) [09:34:26:525]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI85A8.tmp, Entrypoint: ManagedInstall
MSI (s) (40:F0) [09:34:26:525]: Generating random cookie.
MSI (s) (40:F0) [09:34:26:557]: Created Custom Action Server with PID 6492 (0x195C).
MSI (s) (40:D4) [09:34:26:586]: Running as a service.
MSI (s) (40:D4) [09:34:26:587]: Hello, I'm your 32bit Elevated custom action server.
DEBUG: Error 2835:  The control ErrorIcon was not found on dialog ErrorDialog
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2835. The arguments are: ErrorIcon, ErrorDialog, 
Error 1001. Error 1001. Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\system32\Action' or one of its dependencies. The system cannot find the file specified..
MSI (s) (40!4C) [09:34:29:580]: 
MSI (s) (40:94) [09:34:29:584]: Leaked MSIHANDLE (14) of type 790531 for thread 7244
MSI (s) (40:94) [09:34:29:584]: Note: 1: 2769 2: _FBC0CC84_D5B4_41F9_A3EC_98A13BC7E73E.install 3: 1 
DEBUG: Error 2769:  Custom Action _FBC0CC84_D5B4_41F9_A3EC_98A13BC7E73E.install did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: _FBC0CC84_D5B4_41F9_A3EC_98A13BC7E73E.install, 1, 
CustomAction _FBC0CC84_D5B4_41F9_A3EC_98A13BC7E73E.install returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 09:34:29: InstallExecute. Return value 3.

本应该是为了让我们的用户更轻松地简化生活的快速胜利,他们不想编辑配置文件...但现在变成了一场噩梦。 :o(

第二次编辑:

经过很多尝试,只有在自定义操作中指定参数时才会出现错误,如图所示。问题是,在先前的安装屏幕中输入的值无法被读取,因此自定义安装程序毫无用处。

Custom action property screen


1
尝试创建详细的安装日志以查看触发错误的原因:http://setupanddeployment.com/debugging/msi-log。您可以在日志中搜索“返回值3”。 - rmrrm
2个回答

7

在反复摸索了许多小时后,我终于找到了问题所在,更重要的是找到了解决方案。

可以按照此博客所定义的方式将参数传递为“CustomActionData”,但这些参数有点古怪...

我发现文本参数不能在参数名称周围加上引号,应该像这样格式化:

/Param1=[CONFIG_TESTFILE] /Param2=[CONFIG_TESTFOLDER]

此外,要使用目标目录参数,您需要包含引号,但不是以反斜杠结尾,而是要使用空格,就像这样:

/target="[TARGETDIR] "


3
我建议使用 "" 而不是空格来表示文件路径。您可以使用以下代码获取正确的路径:string exePath = Path.Combine(Context.Parameters["targetdir"], "TestForSetup.exe"); var config = ConfigurationManager.OpenExeConfiguration(exePath); - Stef Heyenrath
@Stef 即使有尾随的“\”,您仍需要添加额外的空格,以便安装程序能够正常工作。(如果没有空格,我的安装程序可以成功安装软件,但卸载会失败并显示上述消息。)似乎这是因为安装程序将结尾的“\”视为结束双引号(“)的转义字符。因此,您必须在两者之间插入一个空格。 - Masood Khaari

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接