Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX: register .NET COM component both x86 x64

Tags:

.net

64-bit

com

wix

I have C# COM .dll. I would like to install the .dll once, but have it be registered for both x86 and x64.

Here's the WiX I have for registering only x64:

<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>

How can I write in HKCR\CLSID, HKCR\Wow6432Node\CLSID, HKLM\Software, and HKLM\Software\Wow6432Node all at once?

like image 401
Kevin Smyth Avatar asked Nov 13 '22 03:11

Kevin Smyth


1 Answers

I succeeded registering the same dll on a 64 Bit System for x86 and 64bit by playing around with two Components, one for the 64bit and one for the x86 Registration:

<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-Attributes in the Component Node, changed the Id for the second Component and added the Win64="yes" Attribut. Also I don't duplicate the File. Hope this helps, if you have a lot of dependencies and won't duplicate the Files.

like image 138
gReX Avatar answered Dec 12 '22 18:12

gReX