我正在尝试使用 WiX 3.11.2 安装 .NET Framework 4.7.2 开发的 COM+ 组件。
它失败了,日志中出现以下错误:
行动 14:38:48:RegisterComPlusAssemblies。注册 COM+ 组件
RegisterComPlusAssemblies: DLL: C:\Program Files (x86)\WiXTestingComPlusApplication\NET472ServicedComponent.dll
ComPlusInstallExecute: ExceptionInfo: Code='0', Source='System.EnterpriseServices', Description='未能加载程序集'c:\program files (x86)\wixtestingcomplusapplication\net472servicedcomponent.dll'.', HelpFile='', HelpContext ='0'
ComPlusInstallExecute:错误 0x80020009:无法调用 RegistrationHelper.InstallAssembly() 方法
ComPlusInstallExecute:错误 0x80020009:无法注册 .NET 程序集
ComPlusInstallExecute:错误 0x80020009:无法注册程序集,键:ComPlusAssembly_NET472ServicedComponent
ComPlusInstallExecute:错误 0x80020009:无法注册程序集 CustomAction ComPlusInstallExecute 返回实际错误代码 1603(请注意,如果翻译发生在沙箱内,这可能不是 100% 准确)
在绑定日志中,我可以看到有人尝试使用 .NET 2.0 运行时加载基于 .NET 4.7.2 的 COM+ 组件程序集:
装配活页夹日志条目(11/15/2019 @ 2:38:49 PM)
操作失败。
绑定结果:hr = 0x8013101b。没有可用的描述。
程序集管理器加载自:C:\Windows\Microsoft.NET\Framework\ v2.0.50727 \mscorwks.dll
在可执行文件 C:\Windows\syswow64\MsiExec.exe 下运行
--- 详细的错误日志如下。
=== 预绑定状态信息 ===
日志:用户 = NT AUTHORITY\SYSTEM 日志:where-ref 绑定。位置 = c:\程序文件 (x86)\wixtestingcomplusapplication\net472servicedcomponent.dll
日志:Appbase = file:///C:/Windows/syswow64/
日志:初始 PrivatePath = NULL
日志:动态基础 = NULL
日志:缓存基础 = NULL
日志:AppName = NULL
调用程序集:(未知)。
===
LOG:此绑定在 LoadFrom 加载上下文中开始。
警告:将不会在 LoadFrom 上下文中探测本机图像。本机映像只会在默认加载上下文中进行探测,例如使用 Assembly.Load()。
LOG:未找到应用程序配置文件。
日志:使用 C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config 中的机器配置文件。
日志:正在尝试下载新的 URL 文件:///c:/program files (x86)/wixtestingcomplusapplication/net472servicedcomponent.dll。
LOG:程序集下载成功。尝试设置文件:c:\program files (x86)\wixtestingcomplusapplication\net472servicedcomponent.dll
LOG:进入从源代码运行设置阶段。ERR:从文件中提取清单导入时出错(hr = 0x8013101b)。
ERR:无法完成程序集的设置(hr = 0x8013101b)。探测终止。
错误代码表示COR_E_NEWER_RUNTIME。
WiX 工具集扩展的自定义操作使用本地 DLL 自定义操作来注册 COM+ 应用程序。
看起来它没有使用最新版本的 .NET Framework。有什么办法可以控制吗?
当然,如果 ServicedComponent 使用的是 .NET Framework 2.0,它也可以正常工作。
我在这里为这个问题创建了一个小演示。
更新 - 添加了 WiX wxs 文件内容
<ComponentGroup Id="NET20ServicedComponent" Directory="INSTALLFOLDER">
<Component Id="Component_NET20ServicedComponent" Guid="{49682A46-A29D-45EE-863A-C0F9935CDB35}" KeyPath="yes">
<File Id="File_NET20ServicedComponent.dll" Source="$(var.NET20ServicedComponent.TargetPath)"/>
<File Id="File_NET20ServicedComponent.tlb" Source="$(var.NET20ServicedComponent.TargetDir)NET20ServicedComponent.tlb"/>
<complus:ComPlusApplication Id="ComPlusApplication_NET20ServicedComponent"
Name="NET20ServicedComponent"
Description="Testing NET20ServicedComponent">
<complus:ComPlusAssembly Id="ComPlusAssembly_NET20ServicedComponent"
DllPathFromGAC="no"
DllPath="[#File_NET20ServicedComponent.dll]"
TlbPath="[#File_NET20ServicedComponent.tlb]"
Type=".net"/>
</complus:ComPlusApplication>
</Component>
</ComponentGroup>
<ComponentGroup Id="NET472ServicedComponent" Directory="INSTALLFOLDER">
<Component Id="Component_NET472ServicedComponent" Guid="{885DB376-CF66-4C46-AF14-4436C6B76EB5}" KeyPath="yes">
<File Id="File_NET472ServicedComponent.dll" Source="$(var.NET472ServicedComponent.TargetPath)"/>
<File Id="File_NET472ServicedComponent.tlb" Source="$(var.NET472ServicedComponent.TargetDir)NET472ServicedComponent.tlb"/>
<complus:ComPlusApplication Id="ComPlusApplication_NET472ServicedComponent"
Name="NET472ServicedComponent"
Description="Testing NET472ServicedComponent">
<complus:ComPlusAssembly Id="ComPlusAssembly_NET472ServicedComponent"
DllPathFromGAC="no"
DllPath="[#File_NET472ServicedComponent.dll]"
TlbPath="[#File_NET472ServicedComponent.tlb]"
Type=".net"/>
</complus:ComPlusApplication>
</Component>
</ComponentGroup>