Registering .NET assemblies for COM Interop with x86/x64 compatibility
NB This fragment is essentially the same as REGASM Assembly.dll /codebase
A couple of things are going on in this sample so here's the code and I'll explain it afterwards...
If you were wondering, this is actually for an ASCOM Telescope Driver.
First, I took advice from above and created some platforma variables in a seperate file, you can see those scattered through the XML.
The if-then-else part near the top deals with x86 vs x64 compatibility. My assembly targets 'Any CPU' so on an x64 system, I need to register it twice, once in the 64-bit registry and once in the 32-bit Wow6432Node
areas. The if-then-else sets me up for this, the values are used in a foreach
loop later on. This way, I only have to author the registry keys once (DRY principle).
The file element specifies the actual assembly dll being installed and registered:
Nothing revolutionary, but notice the Assembly=".net"
- this attribute alone would cause the assembly to be put into the GAC, which is NOT what I wanted. Using the AssemblyApplication
attribute to point back to itself is simply a way of stopping Wix putting the file into the GAC. Now that Wix knows it's a .net assembly, though, it lets me use certain binder variables within my XML, such as the !(bind.assemblyFullname.filDriverAssembly)
to get the assembly full name.