.net Windows安装程序:错误1001,CustomAction _xxxxx。安装程序返回实际错误代码1603

.net Windows安装程序:错误1001,CustomAction _xxxxx。安装程序返回实际错误代码1603,.net,windows-services,windows-installer,installshield-2012,.net,Windows Services,Windows Installer,Installshield 2012,问题: 我已经使用Visual Studio 2012和InstallShield为windows服务创建了一个安装程序 服务运行正常。 安装程序在我的开发机器(64位windows 8)和XP虚拟机(32位)上运行良好 但在Windows Server 2008 R2上,同一安装程序会收到“错误10001”。 没有进一步的消息了 事件日志中包含以下信息: Product: DbBackupServiceSetup -- Error 1001. (NULL) (NULL) (NULL) (NU

问题:

我已经使用Visual Studio 2012和InstallShield为windows服务创建了一个安装程序

服务运行正常。
安装程序在我的开发机器(64位windows 8)和XP虚拟机(32位)上运行良好

但在Windows Server 2008 R2上,同一安装程序会收到“错误10001”。
没有进一步的消息了

事件日志中包含以下信息:

Product: DbBackupServiceSetup -- Error 1001. 
(NULL)
(NULL)
(NULL)
(NULL)
(NULL)

the message resource is present but the message is not found in the string/message table
如果使用以下工具手动安装:

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "D:\Program Files\Test\DbBackupService.exe"
即使在Windows Server 2008 R2上,它也可以正常工作

我已经创建了一个32位可执行文件的安装程序和一个64位可执行文件的安装程序,但是我在这两个安装程序上都遇到了这个错误

我已尝试在启用日志记录的情况下执行msi

msiexec /i "D:\Install\DISK1\DbBackupServiceSetup.msi" /Lv "D:\example.log"
日志文件中的第一个错误指示如下:

Created Custom Action Server with PID 3932 (0xF5C).
MSI (s) (C0:74) [14:26:28:065]: Running as a service.
MSI (s) (C0:74) [14:26:28:080]: Hello, I'm your 32bit Elevated custom action server.
MSI (s) (C0!14) [14:26:33:681]: 
MSI (s) (C0:E8) [14:26:33:681]: Leaked MSIHANDLE (16) of type 790531 for thread 3348
MSI (s) (C0:E8) [14:26:33:681]: Note: 1: 2769 2: _B384C869AD7BC0C39F5780609620645B.install 3: 1 
Info 2769. Custom Action _B384C869AD7BC0C39F5780609620645B.install did not close 1 MSIHANDLEs.
CustomAction _B384C869AD7BC0C39F5780609620645B.install returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 14:26:33: InstallFinalize. Return value 3.
MSI (s) (C0:F0) [14:26:33:697]: User policy value 'DisableRollback' is 0
MSI (s) (C0:F0) [14:26:33:697]: Machine policy value 'DisableRollback' is 0
我不明白。
同样的安装程序在其他机器上运行良好。
所有自定义操作都封装在try-catch中,系统帐户可以完全访问文件系统,并且不是网络共享。
并且,使用installutil安装服务是可行的,因此安装程序本身肯定存在错误。

在我看来,它好像在召唤

C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe "D:\Program Files\test\DbBackupService.exe"
而不是

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "D:\Program Files\test\DbBackupService.exe"
并因此得到坏图像异常

然而,如果是这样的话,我不明白的是为什么我会在使用32位和64位可执行文件时出现这个错误

很显然,问题在于InstallShield本身……
哦,我正在使用远程桌面(mstsc.exe)连接到服务器,以防万一,我没有直接访问服务器的权限,因此如果这是mstsc问题,我无法尝试。

错误代码1001始终意味着安装程序类自定义操作失败。InstallShield只是按照您的指示使用/托管它。众所周知,安装程序类自定义操作非常脆弱,并且会耗尽进程,所以您几乎没有日志记录

您应该使用InstallShield在高级组件设置下公开的本机Windows Installer ServiceInstall和ServiceConfigure表,而不是使用自定义操作。创建一个组件,将服务EXE作为密钥文件添加到其中,然后定义服务元

首先,我建议只创建安装,然后在安装后手动启动。一旦工作正常,请添加ServiceControl信息,以便安装程序自动执行。冲洗并在VM上重复


如果安装程序尝试启动服务时出现错误1920,则始终是服务问题。分析它以了解问题,然后修复代码或修复缺少依赖项的安装程序。

通过编写自己的安装程序解决。
我所做的就是将服务项目的输出作为资源嵌入到安装程序项目中,并将它们写入指定的文件夹
然后我以编程方式运行installutil,它可以很好地安装服务,然后它就可以工作了。
与真正的安装程序相比,唯一的缺点是,这种方式没有卸载程序,但我不再在乎了。当使用自己的安装程序比使用InstallShield快几天时,InstallShield就有问题了

重新发明轮子可能会导致错误,但至少这些错误是我自己制造并解决的。
这里是解决方案,以防对其他人有用

using System;
using System.Collections.Generic;
using System.Windows.Forms;


namespace SimpleInstaller
{


    static class Program
    {


        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static int Main(string[] args)
        {
            if (false)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }


            //for (int i = 0; i < args.Length; ++i)
            //{
            //    Console.WriteLine("args[{0}] = {1}", i, args[i]);
            //}


            string strPath = @"C:\pro\DbBackupService\DbBackupService\bin\Debug\DbBackupService.exe";


            string[] callArgs = null;
            string[] argInstall = new string[] { strPath };
            string[] argUnInstall = new string[] { "/u", strPath };

            bool bIsInstallation = true;
            bIsInstallation = false;
            callArgs = bIsInstallation ? argInstall : argUnInstall;


            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture();

            //if(Console.OutputEncoding.CodePage != 65001 && Console.OutputEncoding.CodePage !=
            if (Console.OutputEncoding.CodePage != 65001
                && Console.OutputEncoding.CodePage != System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage
                && Console.OutputEncoding.CodePage != System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage)
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }



            try
            {
                System.Configuration.Install.ManagedInstallerClass.InstallHelper(callArgs);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //return -1;
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(" --- Press any key to continue --- ");
            Console.ReadKey();
            return 0;
        } // End Sub Main


    } // End Class Program


} // End Namespace SimpleInstaller
使用系统;
使用System.Collections.Generic;
使用System.Windows.Forms;
名称空间SimpleInstaller
{
静态类程序
{
/// 
///应用程序的主要入口点。
/// 
[状态线程]
静态int Main(字符串[]args)
{
if(false)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(新Form1());
}
//对于(int i=0;i
通过覆盖我的安装程序类中的所有自定义操作方法解决了这个问题。经过多次尝试,最终它的效果非常好

  public override void Install(IDictionary savedState)
    {
         base.Install(savedState);

    }
 public override void Commit(IDictionary savedState)
    {
        base.Commit(savedState);
    }

    public override void Rollback(IDictionary savedState)
    {
        base.Rollback(savedState);
    }

    public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
    }

您假设主机包装器InstallUtilLib.dll(Microsoft)是防弹的。遗憾的是,它不是。有许多已知的