Error 2896 using a WiX C#/.NET 4 custom action(使用 WiX C#/.NET 4 自定义操作时出现错误 2896)
问题描述
I am trying to use my first custom action in WiX and I get:
error 2896: Executing action CustomActionTest failed.
I am using Visual Studio 2010, WiX 3.5, 64-bit Windows 7 Ultimate, .NET Framework 4.
Here are what I think are the relevant sections:
<Binary Id="JudgeEditionCA" SourceFile="..JudgeEditionCAinDebugJudgeEdition.CA.dll" />
<CustomAction Id="CustomActionTest" BinaryKey="JudgeEditionCA" DllEntry="CustomActionOne" Execute="immediate"/>
<Control Id="Next" Type="PushButton" X="248" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" >
<Publish Event="DoAction" Value="CustomActionTest">1</Publish>
<Publish Event="DoAction" Value="InvalidClientDesc">CLIENT_DESC_VALID = "0"</Publish>
<Publish Event="NewDialog" Value="VerifyReadyDlg">CLIENT_DESC_VALID = "1"</Publish>
</Control>
From the action:
namespace JudgeEditionCA
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomActionOne( Session session )
{
return ActionResult.Success;
}
}
}
And the configuration file from the custom action:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="false">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
And finally I have used a project reference in my WiX project to the custom action. I am not sure what I am doing wrong.
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
这篇关于使用 WiX C#/.NET 4 自定义操作时出现错误 2896的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 WiX C#/.NET 4 自定义操作时出现错误 2896


- 如何用自己压缩一个 IEnumerable 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01