使用维克斯C#错误2896 /。NET 4自定义操作 [英] Error 2896 using a WiX C#/.NET 4 custom action
问题描述
我试图使用维克斯我的第一个自定义操作,我得到:
I am trying to use my first custom action in WiX and I get:
错误2896:执行行动CustomActionTest失败。
error 2896: Executing action CustomActionTest failed.
我使用Visual Studio 2010,维克斯3.5,64位Windows 7旗舰版的.NET Framework 4。
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="..\JudgeEditionCA\bin\Debug\JudgeEdition.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>
从动作:
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.
推荐答案
我想它运行我的微星使用/ LVX选项来获得一个详细日志记录。我也有我的动作移动到InstallExecuteSequence部分得到一个有意义的错误消息。当调用CA在按钮没有意义返回
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:无法加载文件或程序集JudgeEdition或它的一个依赖。这个组件由一运行时间比当前加载运行时更新构建并不能装载。的
我改变了useLegacyV2RuntimeActivationPolicy属性为true。一切开始工作很好。
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:
- http://stackoverflow.com/questions/1604663/what-does-uselegacyv2runtimeactivationpolicy-do-in-the-net-4-config/2467255#2467255
- http://www.marklio.com/marklio/PermaLink,guid,ecc34c3c- be44-4422-86b7-900900e451f9.aspx
- http://stackoverflow.com/questions/1604663/what-does-uselegacyv2runtimeactivationpolicy-do-in-the-net-4-config/2467255#2467255
- http://www.marklio.com/marklio/PermaLink,guid,ecc34c3c-be44-4422-86b7-900900e451f9.aspx
这篇关于使用维克斯C#错误2896 /。NET 4自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!