内置用于.NET Framework 4.0维克斯自定义操作不起作用?方法来解决?自定义、方法来、维克、不起作用

由网友(给脸别傲)分享简介:我们正在使用WIX 3.5(内部版本号1811),并内置使用Visual Studio 2008和目标框架NET 3.5的内置自定义操作。这用来工作的伟大,直到我们使用Visual Studio 2010和目标框架.NET 4.0中内置的自定义操作。维克斯无法调用自定义操作,我们得到的错误是这样的:SFXCA:提取自定...

我们正在使用WIX 3.5(内部版本号1811),并内置使用Visual Studio 2008和目标框架NET 3.5的内置自定义操作。这用来工作的伟大,直到我们使用Visual Studio 2010和目标框架.NET 4.0中内置的自定义操作。

维克斯无法调用自定义操作,我们得到的错误是这样的:

  SFXCA:提取自定义操作来临时目录:C: WINDOWS  Installer程序 MSI69BD.tmp- 
    SFXCA:绑定到CLR版本V2.0.50727
    调用自定义操作SomeCompany.SomeProduct.InstallerPlugin!SomeCompany.SomeProduct.InstallerPlugin.XYZProductCustomAction.ABCMethod
    错误:未能从程序集加载自定义动作类SomeCompany.SomeProduct.InstallerPlugin.XYZProductCustomAction:SomeCompany.SomeProduct.InstallerPlugin

    System.BadImageFormatException:未能加载文件或程序集SomeCompany.SomeProduct.InstallerPlugin或它的某一个依赖。这个组件由一运行时间比当前加载运行时更新的构建并不能装载。

    文件名:SomeCompany.SomeProduct.InstallerPlugin
       在System.Reflection.Assembly._nLoad(的AssemblyName文件名,字符串codeBase的,证据assemblySecurity,大会locationHint,StackCrawlMark和放大器; stackMark,布尔throwOnFileNotFound,布尔forIntrospection)
       在System.Reflection.Assembly.nLoad(的AssemblyName文件名,字符串codeBase的,证据assemblySecurity,大会locationHint,StackCrawlMark和放大器; stackMark,布尔throwOnFileNotFound,布尔forIntrospection)
       在System.Reflection.Assembly.InternalLoad(的AssemblyName assemblyRef,证据assemblySecurity,StackCrawlMark和放大器; stackMark,布尔forIntrospection)
       在System.Reflection.Assembly.InternalLoad(字符串assemblyString,证据assemblySecurity,StackCrawlMark和放大器; stackMark,布尔forIntrospection)
       在System.AppDomain.Load(字符串assemblyString)
       在Microsoft.Deployment.WindowsInstaller.CustomActionProxy.GetCustomActionMethod(会话的会话,字符串的AssemblyName,类名字符串,字符串方法名)
 

解决方案

嗯,我们终于解决了这个问题,我们必须设置:

  useLegacyV2RuntimeActivati​​onPolicy =真
和
有指定的两个版本:
< supportedRuntime版本=V2.0.50727/>
和
< supportedRuntime版本=V4.0/>
 
软件程序 NET Framework

如果只是< supportedRuntime版本=V4.0/> 被指定,它不工作所以看起来像维克斯3.5测试版

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 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"/>

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

阅读全文

相关推荐

最新文章