WiX:注册 x86 x64 的 .NET COM 组件

2024-03-07

我有 C# COM .dll。我想安装 .dll 一次,但将其注册为 x86 和 x64。

这是我仅用于注册 x64 的 WiX:

<Component Id="NETDLL.dll" Directory="INSTALLDIR">
  <File Id="NETDLL.dll" Name="NETDLL.dll" KeyPath="yes" Source="..\NETDLL.dll" />
  <Class Id="{78BE...}" Context="InprocServer32" Description="NETDLL" ThreadingModel="both" ForeignServer="mscoree.dll">
    <ProgId Id="NETDLL" Description="NETDLL" />
  </Class>
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32\1.0.1.0" Name="Class" Value="NETDLL" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32\1.0.1.0" Name="Assembly" Value="NETDLL, Version=1.0.1.0, Culture=neutral" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32\1.0.1.0" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32\1.0.1.0" Name="CodeBase" Value="file:///[#NETDLL.dll]" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32" Name="Class" Value="NETDLL" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32" Name="Assembly" Value="NETDLL, Version=1.0.1.0, Culture=neutral" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\InprocServer32" Name="CodeBase" Value="file:///[#NETDLL.dll]" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="Component Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Name="0" Value=".NET Category" Type="string" Action="write" />
  <RegistryKey Root='HKLM' Key='Software\NETDLL'>
    <RegistryValue Name='Description' Type='string' Value='NETDLL'/>
  </RegistryKey>
</Component>

如何同时写入 HKCR\CLSID、HKCR\Wow6432Node\CLSID、HKLM\Software 和 HKLM\Software\Wow6432Node ?


我通过使用两个组件(一个用于 64 位,一个用于 x86 注册)成功在 64 位系统上为 x86 和 64 位注册相同的 dll:

<Component Id="NETDLL.dll" Directory="INSTALLDIR" Guid="*">
   <Class Id="{78BE...}" Context="InprocServer32" Description="NETDLL"  
        ThreadingModel="both" ForeignServer="mscoree.dll">
      <ProgId Id="NETDLL" Description="NETDLL" />
   </Class>
   <File Id="NETDLL.dll" Name="NETDLL.dll" KeyPath="yes" 
          Source="..\NETDLL.dll" />
   <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\Implemented Categories {62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />
   ...
</Component>
<Component Id="NETDLLWin64.dll" Guid="{885F75B1-3046-42BD-8B37-F8FA0E8D7A51}" Win64="yes" Directory="INSTALLDIR">
   <Class Id="{78BE...}" Context="InprocServer32" Description="NETDLL" ThreadingModel="both" ForeignServer="mscoree.dll">
      <ProgId Id="NETDLL" Description="NETDLL" />
   </Class>
   <RegistryValue Root="HKCR" Key="CLSID\{78BE...}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />  
   ...
</Component>

I added Guid- 组件节点中的属性,更改了第二个组件的 Id 并添加了Win64=“是”属性。我也不复制该文件。如果您有很多依赖项并且不会重复文件,希望这会有所帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

WiX:注册 x86 x64 的 .NET COM 组件 的相关文章

随机推荐