基于Wix安装程序的TopShelf Windows服务无法启动

编程入门 行业动态 更新时间:2024-10-28 10:27:30
本文介绍了基于Wix安装程序的TopShelf Windows服务无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用TopShelf和Quartz编写了一个基本的.NET 4.7.2 C#Windows服务.当我在Windows 10笔记本电脑上使用Visual Studio 2019对其进行调试时,该服务将起作用.然后,我创建了一个基于Wix 3.11.2的安装程序来安装和启动此服务.现在,我正在尝试使用此安装程序在笔记本电脑上安装该服务.安装程序可以复制文件,但无法启动服务.这是代码:

I have written a bare-bones .NET 4.7.2 C# Windows Service using TopShelf and Quartz. The service works when I debug it using Visual Studio 2019 on my Windows 10 laptop. I then created a Wix 3.11.2 based setup to install and start this service. Now, I am trying to install the service on my laptop using this installer. The installer is able to copy the files but fails to start the service. Here is the code:

Product.wxs

Product.wxs

<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="schemas.microsoft/wix/2006/wi"> <Product Id="*" Name="Broker Test" Language="1033" Version="1.0.0.0" Manufacturer="Test" UpgradeCode="{68813F65-1022-4E32-AC50-CD16B5927DAD}"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Media Id="1" Cabinet="BrokerTest.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="INSTALLDIR" Name="Application"> <Directory Id="WINDIR" Name="Service"/> </Directory> </Directory> <Feature Id="ProductFeature" Title="BrokerTest_MSI" Level="1"> <ComponentGroupRef Id="BrokerWindowsService" /> </Feature> <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> <Property Id="INSTALLTYPE" Value="1"/> </Product> </Wix>

WinService.wxs

WinService.wxs

<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="schemas.microsoft/wix/2006/wi" xmlns:util="schemas.microsoft/wix/UtilExtension"> <Fragment> <ComponentGroup Id="BrokerWindowsService"> <ComponentRef Id="Tb.WinService.Test" /> <ComponentRef Id="TopShelf"/> <ComponentRef Id="Tb.ServiceConfig" /> <ComponentRef Id="Microsoft.Extensions.DependencyInjection" /> <ComponentRef Id="Microsoft.Extensions.DependencyInjection.Abstractions" /> <ComponentRef Id="Quartz" /> </ComponentGroup> <DirectoryRef Id="WINDIR"> <Directory Id="DataDir" Name="Data"/> <Component Id="Tb.WinService.Test" Guid="{F1DF09D9-98D8-4D63-9BB9-7581D56E1685}"> <CreateFolder Directory="DataDir"> <util:PermissionEx User="NT Authority\SYSTEM" GenericAll="yes"/> </CreateFolder> <File Id="Tb.WinService.Test.dll" Name="$(var.Tb.WinService.Test.TargetFileName)" Source="$(var.Tb.WinService.Test.TargetPath)" /> <File Id="Tb.WinService.Test.pdb" Name="$(var.Tb.WinService.Test.TargetName).pdb" Source="$(var.Tb.WinService.Test.TargetDir)$(var.Tb.WinService.Test.TargetName).pdb" /> <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" Name="BrokerWindowsServiceTest" DisplayName="Broker Windows Service Test" Description="Runs scheduled tasks" Start="auto" Account="NT Authority\SYSTEM" ErrorControl="ignore" Interactive="no" /> <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="BrokerWindowsServiceTest" Wait="yes" /> </Component> <Component Id="TopShelf" Guid="{CEC3596B-4D38-4641-81EF-CBC09C4FE67E}"> <File Id="TopShelf.dll" Name="TopShelf.dll" Source="$(var.SolutionDir)packages\Topshelf.4.2.1\lib\net452\Topshelf.dll" Vital="yes" /> <File Id="TopShelf.xml" Name="TopShelf.xml" Source="$(var.SolutionDir)packages\Topshelf.4.2.1\lib\net452\Topshelf.xml" Vital="yes" /> </Component> <Component Id="Tb.ServiceConfig" Guid="{A08D1440-4B2A-4DFB-9F55-27E81DC4B106}"> <File Id="Tb.Service.App.Config" Name="$(var.Tb.WinService.Test.TargetName).exe.config" Vital="yes" KeyPath="yes" Source="$(var.Tb.WinService.Test.TargetDir)App.config" /> </Component> <Component Id="Microsoft.Extensions.DependencyInjection" Guid="{8F69CFC4-02F9-479C-9C57-E2F88180E542}"> <File Id="Microsoft.Extensions.DependencyInjection.dll" Name="Microsoft.Extensions.DependencyInjection.dll" Source="$(var.SolutionDir)packages\Microsoft.Extensions.DependencyInjection.3.0.1\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll" Vital="yes" /> </Component> <Component Id="Microsoft.Extensions.DependencyInjection.Abstractions" Guid="{8EB47289-9527-4CE4-9991-EBF8997368DC}"> <File Id="Microsoft.Extensions.DependencyInjection.Abstractions.dll" Name="Microsoft.Extensions.DependencyInjection.Abstractions.dll" Source="$(var.SolutionDir)packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.0.1\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll" Vital="yes" /> </Component> <Component Id="Quartz" Guid="{345DA6DA-F385-47A6-844C-3171ADE42E83}"> <File Id="Quartz.dll" Name="Quartz.dll" Source="$(var.SolutionDir)packages\Quartz.3.0.7\lib\net452\Quartz.dll" Vital="yes" /> <File Id="Quartz.xml" Name="Quartz.xml" Source="$(var.SolutionDir)packages\Quartz.3.0.7\lib\net452\Quartz.xml" Vital="yes" /> </Component> </DirectoryRef> </Fragment> </Wix>

运行Wix安装程序时出现以下错误:

I get the following error when I run the Wix Installer:

如果我尝试手动启动该服务,则会出现以下错误:

If I try to start the service manually, I get the following error:

我已经尝试了以下方法:

I have already tried the following:

  • 我正在使用应该具有适当访问权限的NT Authority \ System帐户.
  • 当前,我的Windows服务实际上并没有做任何事情.它正在重播Task.CompletedTask.因此,不应有超时情况.
  • 我尝试过调试和发布版本.
  • 我正在安装要开发的同一台计算机.因此,.NET Framework版本不应该成为问题.
  • 我尝试启动调试器,但无法连接.所以我没有更多的细节.
  • 我捕获了异常并写入了事件日志,但这也没有更多详细信息.
  • 推荐答案

    确保ServiceInstall名称与您的topshelf服务名称完全匹配

    Make sure the ServiceInstall Name exactly matches the name of your topshelf service

    更多推荐

    基于Wix安装程序的TopShelf Windows服务无法启动

    本文发布于:2023-11-06 22:04:32,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1564793.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:安装程序   无法启动   Wix   Windows   TopShelf

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!