我已经使用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:
确保ServiceInstall名称与您的topshelf服务名称完全匹配
Make sure the ServiceInstall Name exactly matches the name of your topshelf service
更多推荐
基于Wix安装程序的TopShelf Windows服务无法启动
发布评论