我试图在WiX中使用我的第一个自定义动作,我得到:
error 2896: Executing action CustomActionTest Failed.
我使用的是Visual Studio 2010,WiX 3.5,64位Windows 7旗舰版,.NET Framework 4.
以下是我认为的相关部分:
<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; } } }
<configuration> <startup useLegacyV2RuntimeActivationPolicy="false"> <supportedRuntime version="v4.0" /> </startup> </configuration>
最后我在WiX项目中使用了一个项目引用来进行自定义操作.我不知道我在做错什么
解决方法
我通过使用/ lvx选项运行我的msi来获得详细的日志记录.我也不得不将我的操作移到InstallExecuteSequence部分以获得有意义的错误消息.当呼叫CA在PushButton没有任何有意义的返回.
<InstallExecuteSequence> <Custom Action='CustomActionTest' After='InstallFinalize' /> </InstallExecuteSequence>
System.BadImageFormatException:无法加载文件或程序集“JudgeEdition”或其依赖关系之一.此程序集由运行时间比当前加载的运行时更新而无法加载.
我将useLegacyV2RuntimeActivationPolicy属性更改为true.一切都开始好运
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> </configuration>
> What does ‘useLegacyV2RuntimeActivationPolicy’ do in the .NET 4 config?
> http://www.marklio.com/marklio/PermaLink,ecc34c3c-be44-4422-86b7-900900e451f9.aspx