【发布时间】:2020-01-10 16:06:21
【问题描述】:
我不得不将我的项目更改为 x64,现在按照this 教程,我尝试将我的 WIX 安装也更改为 x64。但是 WIX 安装会尝试安装 Windows 服务。此服务在 install.log 中使用msiexec /i Setup.msi /L*V install.log 引发以下异常:
System.Reflection.TargetInvocationException:调用目标导致异常。 ---> System.BadImageFormatException:找不到文件或程序集“Service,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”或对它的依赖。试图加载格式错误的文件。
在 SaveServiceConfigurationAction.CustomActions.SaveServiceConfiguration(会话会话)
--- 内部异常批量监控结束---
bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
北 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfoculture)
在 Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)CustomAction SaveServiceConfigurationAction 返回实际错误代码 1603(请注意,如果翻译发生在沙箱内,这可能不是 100% 准确)
当我尝试使用 installutil.exe 安装此服务时,我遇到了类似的异常
System.BadImageFormatException:找不到文件或程序集“Service.exe”或其依赖项。试图加载格式错误的文件。
但如果我使用Framework64\v4.0.30319\installutil.exe,则可以毫无问题地安装该服务。
所以现在我的问题是:如何配置我的 WIX 项目以使用 Framework64 安装服务?
我的 WIX 代码:
<Component Id="CMP_Service" Feature="Core">
<File Source="$(var.Service.TargetPath)" KeyPath="yes">
<fire:FirewallException Id="ServiceException" Name="Service Exception" Protocol="tcp" Port="[PORTProperty]" Scope="any" />
</File>
<ServiceInstall Id="ServiceInstallELS"
Name="Service"
Description="..."
Start="auto"
Account="[SERVICEACCOUNT]"
ErrorControl="normal"
Type="ownProcess"
Vital="no" />
<ServiceControl Id="ServiceControllELS"
Name="Service"
Start="install"
Stop="both"
Remove="uninstall"
Wait="no" />
</Component>
【问题讨论】:
-
你能分享一下英语的错误吗?您可以使用自己的自定义操作来安装服务
-
是的,我发现了这个:stackoverflow.com/questions/17785669/… 但不认为这是一个好的解决方案
-
我也不知道 installutil.exe 是否总是存储在同一个地方
标签: wix windows-services wix3.7 badimageformatexception