为 .Net Framework 4.0 构建的 WIX 自定义操作不起作用?解决方法? [英] WIX Custom Actions built for .Net Framework 4.0 does not work? Ways to resolve?

查看:35
本文介绍了为 .Net Framework 4.0 构建的 WIX 自定义操作不起作用?解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用的是 WIX 3.5(内部版本号 1811)并构建了使用 Visual Studio 2008 构建的自定义操作,目标框架为 .Net 3.5.在我们使用 Visual Studio 2010 和目标框架为 .Net 4.0 构建自定义操作之前,这曾经很有效.

We were using WIX 3.5 (Build Number 1811) and built a custom action built using Visual Studio 2008 and with target framework as .Net 3.5. This used to work great, until we built the custom action using Visual Studio 2010 and with target framework as .Net 4.0.

WIX 无法调用自定义操作,我们得到的错误是:

WIX is unable to invoke the custom action, the error that we get is this:

  SFXCA: Extracting custom action to temporary directory: C:WindowsInstallerMSI69BD.tmp-
    SFXCA: Binding to CLR version v2.0.50727
    Calling custom action SomeCompany.SomeProduct.InstallerPlugin!SomeCompany.SomeProduct.InstallerPlugin.XYZProductCustomAction.ABCMethod
    Error: could not load custom action class SomeCompany.SomeProduct.InstallerPlugin.XYZProductCustomAction from assembly: SomeCompany.SomeProduct.InstallerPlugin

    System.BadImageFormatException: Could not load file or assembly 'SomeCompany.SomeProduct.InstallerPlugin' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    File name: 'SomeCompany.SomeProduct.InstallerPlugin'
       at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.AppDomain.Load(String assemblyString)
       at Microsoft.Deployment.WindowsInstaller.CustomActionProxy.GetCustomActionMethod(Session session, String assemblyName, String className, String methodName)

推荐答案

好吧,我们终于解决了问题,我们必须设置:

Well we finally resolved the problem, we had to set:

useLegacyV2RuntimeActivationPolicy="true"
and
have both versions specified:
<supportedRuntime version="v2.0.50727"/>
and
<supportedRuntime version="v4.0"/>

如果只指定了 "<supportedRuntime version="v4.0"/>,则它不起作用.所以看起来像 WIX 3.5 Beta 中的错误

If just "<supportedRuntime version="v4.0"/> is specified, it does not work. So looks like a bug in WIX 3.5 Beta

这篇关于为 .Net Framework 4.0 构建的 WIX 自定义操作不起作用?解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆