我在 .Net Core 中有一个 Windows 服务,它通过 WIX 安装程序安装。
目前我手动注册时:
sc create MyService binPath= "D:\My\Path\Release\MyService.exe" DisplayName= "MyService" start= auto
它完美地工作并取得了成功。但是在我的 WIX 设置中,我有以下设置:
<Component Id="Xms_HostService" Guid="72044696-3E92-4928-BC6D-5A9C3ABB924A" SharedDllRefCount="yes">
<File Id="MyService.exe"
Name="MyService.exe"
KeyPath="yes"
Vital="no"
Compressed="default"
DiskId="1"
Source="$(var.buildDirectory)\MyService.exe" />
<ServiceInstall Id="MyService"
Name="MyService"
Type="ownProcess"
Interactive="no"
Start="auto"
Account="LocalSystem"
ErrorControl="critical"
Vital="yes" />
<ServiceControl Id="StartService"
Start="install"
Wait="no" />
<ServiceControl Id="Uninstall"
Name="StopService"
Stop="both"
Remove="uninstall" />
</Component>
<Component Id="MyService_Files" Guid="4DC25232-0B8D-4C16-ABC9-5BD5B45D0358" SharedDllRefCount="yes">
<File Id="MyService.dll" Name="MyService.dll" Vital="no" Compressed="default" DiskId="1" Source="$(var.buildDirectory)\MyService.dll" />
<File Id="MyService.dll.config" Name="MyService.dll.config" Vital="no" Compressed="default" DiskId="1" Source="$(var.buildDirectory)\MyService.dll.config" />
<File Id="MyService.runtimeconfig.json" Name="MyService.runtimeconfig.json" Vital="no" Compressed="default" DiskId="1" Source="$(var.buildDirectory)\MyService.runtimeconfig.json" />
<File Id="MyServiceCore.dll" Name="MyServiceCore.dll" Vital="no" Compressed="default" DiskId="1" Source="$(var.buildDirectory)\MyServiceCore.dll" />
</Component>
失败并出现以下错误:
[B9A8:B850][2023-05-11T14:46:53]e000: Error 0x80070002: Failed to find payload: MyAppMsi in working path: C:\WINDOWS\Temp\{5B0118D2-90A3-4CF2-8793-79EA34A746D4}\MyAppMsi and unverified path: C:\ProgramData\Package Cache\.unverified\MyAppMsi
如果我只是评论
ServiceControl
启动服务(这意味着它没有通过设置启动,设置完成,但是当我尝试启动服务时,我得到这个错误:
我查了那些错误,它们似乎表明找不到某些文件。 但是使用 winmerge,比较我的发布输出和设置生成的内容,我看不到重要的丢失文件(我看到很多 deps.json 或 xml 或 pdb,但它们似乎都是一些构建文件)。
我找不到任何地方(windows日志,我的应用程序日志)找不到哪个DLL。
有人知道如何获得有关此类问题的更多调试信息吗?
我刚找到一个日志文件:
Rolling back assembly 'C:\Program Files\MyCompany\MyApp\Bin\MyService.exe'.
Affected parameters are:
assemblypath = C:\Program Files\MyCompany\MyApp\Bin\MyService.exe
logfile = C:\Program Files\MyCompany\MyApp\Bin\MyService.InstallLog
Unable to create an instance of the my.app.MyService.MyServiceInstaller installer type.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
The inner exception System.TypeInitializationException was thrown with the following error message: The type initializer for '1' threw an exception..
The inner exception System.TypeLoadException was thrown with the following error message: Could not load type '' from assembly 'System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'..
但这对我帮助不大。我不确定在版本 4.0.0 中有与“System.Configuration.Install”相关的东西是否正常?