2

问题:

我使用 Visual Studio 2012 和 InstallShield 为 Windows 服务创建了安装程序。

服务运行良好。
安装程序在我的开发机器(windows 8 64 位)和我的 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 问题,我无法尝试。

4

3 回答 3

4

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

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

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

如果在安装程序尝试启动服务时收到错误 1920,这始终是服务问题。对其进行分析以了解问题,然后修复代码或修复安装程序(如果它缺少依赖项)。

于 2013-05-22T13:44:35.180 回答
3

通过编写我自己的安装程序来解决。
我所做的只是将服务项目的输出作为资源嵌入到安装程序项目中,并将它们写入指定的文件夹。
然后我以编程方式运行 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
于 2013-05-23T10:18:48.287 回答
1

通过覆盖我的安装程序类中的所有自定义操作方法来解决。经过大量尝试,终于它像一个魅力。

  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);
    }
于 2018-03-19T13:32:15.603 回答