0

I have a .Net assembly that requires registration for COM Interop. It all works fine when building the solution in visual studio and enabling the Register for Com interop property. Now I try to achieve the same thing using WiX and for that I have harvested the dll using Heat.exe. It works fine and after executing the msi, the entries written in the registry are exactly the same as those when building from visual studio. But when I try to load the the assembly I have the following error:

System.IO.FileLoadException
  HResult=0x80131040
  Message=Retrieving the COM class factory for component with CLSID {XXX} failed due to the following error: 80131040 The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
  Source=mscorlib
  StackTrace:
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

I have made sure that I have only one version of the dll. Any idea on what could be wrong ?

m3shoot
  • 23
  • 3
  • To analyze, you can enable fusion logs as described e.g. here: https://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net. – Klaus Gütter Jul 04 '21 at 13:56

1 Answers1

0

Enabling fusion log as pointed out by Klaus has been really helpful. I had accidently signed the assembly with a different key and not changed PublicKeyToken in the WiX .wxs file.

m3shoot
  • 23
  • 3