nmd*_*mdr 15 .net wix .net-4.0 wix3.5
我们使用的是WIX 3.5(Build Number 1811),并构建了一个使用Visual Studio 2008构建的自定义操作,并将目标框架构建为.Net 3.5.在我们使用Visual Studio 2010和目标框架作为.Net 4.0构建自定义操作之前,这曾经很好用.
WIX无法调用自定义操作,我们得到的错误是:
SFXCA: Extracting custom action to temporary directory: C:\Windows\Installer\MSI69BD.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)
Run Code Online (Sandbox Code Playgroud)
Den*_*els 27
只是我的两分钱:
与Ngm不同,我只需要为.NET 4.0添加supportedRuntime
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)
重要:
好吧,我们终于解决了问题,我们必须设置:
useLegacyV2RuntimeActivationPolicy="true"
and
have both versions specified:
<supportedRuntime version="v2.0.50727"/>
and
<supportedRuntime version="v4.0"/>
Run Code Online (Sandbox Code Playgroud)
如果只是"<supportedRuntime version="v4.0"/>指定,它不起作用.所以看起来像WIX 3.5 Beta中的一个错误