Error 2896 using a WiX C#/.NET 4 custom action
As a corollary to KnightsArmy's answer this error is also thrown when the DllEntry attribute on the CustomAction element is wrong. In my case I had a typo and the only error information I could get out of the log was the infamous error 2896.
I figured it out by running my msi with the /lvx option to get a verbose logging. I also had to move my action to the InstallExecuteSequence section to get a meaningful error message. When the call to the CA was in the PushButton nothing meaningful was returned.
<InstallExecuteSequence>
<Custom Action='CustomActionTest' After='InstallFinalize' />
</InstallExecuteSequence>
System.BadImageFormatException: Could not load file or assembly 'JudgeEdition' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I changed the useLegacyV2RuntimeActivationPolicy attribute to true. Everything started working nicely.
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
These links helped get me up to speed:
- What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?
- http://www.marklio.com/marklio/PermaLink,guid,ecc34c3c-be44-4422-86b7-900900e451f9.aspx