简体   繁体   English

使用WiX进行MajorUpgrade后无法启动Windows服务

[英]Failing to start Windows service after a MajorUpgrade with WiX

I have a pretty straight forward WiX project. 我有一个非常简单的WiX项目。 Nothing fancy. 没有什么花哨。 When trying to perform a MajorUpgrade over an existing installation, it is unable to start the service and inevitably rolls back to the previous version and starts the service just fine. 尝试对现有安装执行MajorUpgrade时,它无法启动服务,因此不可避免地回滚到以前的版本并正常启动服务。 I have removed the Start="install" and manually started the application successfully, so I know it's not a dependency issue. 我已经删除了Start="install"并成功手动启动了该应用程序,因此我知道这不是依赖性问题。

I have searched endlessly and found no answers to my problem. 我进行了无休止的搜索,没有找到解决问题的答案。

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallFinalize" />

My service install: 我的服务安装:

<ServiceInstall
        Id="ServiceInstaller"
        Type="ownProcess"
        Name="LsdnService"
        DisplayName="Lsdn Service"
        Description="Placeholder for now."
        Start="auto"
        Account="[SERVICEACCOUNT]"
        Password="[SERVICEPASSWORD]"
        ErrorControl="normal"/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="LsdnService" Wait="yes" />

I dumped the MSI log to a file and got this error but it is quite vague. 我将MSI日志转储到文件中并收到此错误,但它非常模糊。

MSI (s) (18:48) [22:41:27:349]: Note: 1: 2205 2:  3: Error 
MSI (s) (18:48) [22:41:27:349]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1920 

There are some registry modifications during an installation. 在安装过程中对注册表进行了一些修改。 The installer attempts to read from the registry and inherit the already existing values. 安装程序尝试从注册表中读取并继承已经存在的值。

<Property Id="LSDNADDRESS" Value="127.0.0.1">
  <RegistrySearch Id="LsdnAddressProperty" Root="HKLM" Key="$(var.RegistryKey)" Name="LsdnAddress" Type="raw" />
</Property>
<Property Id="LSDNPORT" Value="9920">
  <RegistrySearch Id="LsdnPortProperty" Root="HKLM" Key="$(var.RegistryKey)" Name="LsdnPort" Type="raw" />
</Property>
<Property Id="LSDNKEY" Value="6f380b07-0b54-4904-8303-95d1ec45d453">
  <RegistrySearch Id="LsdnKeyProperty" Root="HKLM" Key="$(var.RegistryKey)" Name="LsdnKey" Type="raw" />
</Property>

Debugging Results : Following a lot of debugging (by original poster - OP) this turned out to be a known MSI issue described here: https://wix-users.narkive.com/EMfQPDrM/a-bug-get-reg-sz-when-using-type-integer . 调试结果 :经过大量调试(由原始海报-OP进行),结果证明是此处描述的已知MSI问题: https : //wix-users.narkive.com/EMfQPDrM/a-bug-get-reg-sz -使用类型整数时 Nice search work. 不错的搜索工作。

What is in a DWORD? DWORD中有什么? (a REG_SZ apparently): Essentially MSI "converts" a DWORD value found via a RegistrySearch operation to a formatted string - REG_SZ - during upgrade installations (could be more involved too). (显然是REG_SZ ):本质上,MSI在升级安装过程中将通过RegistrySearch操作找到的DWORD值“转换”为格式化的字符串REG_SZ (可能涉及更多)。 This causes services that expect a DWORD value to fall over on startup during major upgrades. 这会导致期望DWORD值的服务在重大升级期间在启动时掉落。 A very exotic error . 一个非常奇怪的错误

Workaround : One can try to "solve" this problem by making the service code capable of reading both DWORD and REG_SZ . 解决方法 :通过使服务代码能够读取DWORDREG_SZ可以尝试“解决”此问题。 This yields a more robust solution than solving the problem in a custom action since it is a "permanent" fix as long as the code is in there (and the presence of the code alerts other developers about the problem). 与在自定义操作中解决问题相比,这提供了一种更健壮的解决方案,因为只要其中有代码(这是存在的代码,就会向其他开发人员发出有关该问题的警报),它便是“永久性”修复程序。 Or maybe use only REG_SZ ? 或者也许只使用REG_SZ


Quick Checks : Check the service password and login - obviously. 快速检查 :很明显,请检查服务密码并登录 Anything in the Event Viewer ? 事件查看器中有任何内容吗? Windows Key + Tap R + eventvwr.msc + Enter . Windows键 +点击R + eventvwr.msc + Enter How to use the Event Viewer to troubleshoot problems with a Windows Service . 如何使用事件查看器对Windows Service问题进行故障排除 Perhaps you can try to do a folder diff on the before and after folders and see if you see something unexpected in the config files ? 也许您可以尝试对之前和之后的文件夹进行文件夹比较 ,看看是否在配置文件中看到了意外情况? Naturally there will be lots of binary differences, but check the text files (also encoding). 自然会有很多二进制差异,但是请检查文本文件(也可以编码)。 Check the MSI log file again and search for "value 3" as described here: Tips For Checking MSI Log Files . 再次检查MSI日志文件 ,然后按照此处所述搜索"value 3"检查MSI日志文件的提示 Manually copy the new files in place and attempt to start the service via the services.msc applet . Manually copy the new files in place and attempt to start the service via the services.msc applet


Service Experts : Windows Services Frequently Asked Questions (FAQ) . 服务专家Windows服务常见问题解答(FAQ) Content seems to be up to date - at face value at least. 内容似乎是最新的-至少以面值计。 These guys claim to be experts on services. 这些家伙自称是服务专家。 I have no idea who they are. 我不知道他们是谁。

Look in the "Errors" section in the link above. 查看上方链接中的“错误”部分 Here are some extracts: 以下是一些摘录:


Generic Check Lists : If none of the above does anything, maybe try these "torpedoes full spread" check-lists (just ideas to start debugging): 通用检查清单 :如果以上都不做任何事情,请尝试以下"torpedoes full spread" check-lists (只是开始调试的想法):


General Purpose Debugging : Throwing in some general-purpose debugging approaches. 通用调试 :抛出一些通用调试方法。


Some Further Links : 其他链接

It certainly could be a dependency issue. 当然,这可能是一个依赖性问题。 For example, GAC / WinSXS files don't get installed into the GAC until the commit phase which is after StartServices. 例如,GAC / WinSXS文件直到StartServices之后的提交阶段才安装到GAC中。

I would leave the Start="Install" in and while it's sitting at the failed to start prompt inspect the state of the machine and debug the service start manually. 我将把Start =“ Install”留在其中,当它坐在无法启动的提示下,检查计算机的状态并手动调试服务启动。 I bet you'll find something missing. 我敢打赌,您会发现缺少的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM