首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WIX CustomAction加载CLR4.0而不是2.0

WIX CustomAction加载CLR4.0而不是2.0
EN

Stack Overflow用户
提问于 2012-06-19 05:40:11
回答 1查看 3.7K关注 0票数 3

我正在尝试编写一个c#自定义操作并使用.Net 2,但是我似乎无法让事情正常工作。我认为MSI使用了错误的CLR版本。我在上面几行日志文件中看到了这一点,其中MSI正在调用我的CA (如果我注释掉我的CA,就不会出现这一行):

代码语言:javascript
复制
SFXCA: Binding to CLR version v4.0.30319. 

我的自定义操作似乎没有加载(假设是因为我没有看到任何日志记录消息)。我使用的是Wiz 3.6.3014.0。这是否受支持,或者Windows Installer是否仅使用计算机上可用的最新运行时?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-19 07:37:46

当您使用WiX创建一个C#自定义操作项目时,默认情况下会创建一个名为CustomAction.config的XML文件。此文件的目的是指示sfxca.dll在运行代码时使用哪个版本的CLR。此文件的默认实现如下所示:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">

        <!--
          Use supportedRuntime tags to explicitly specify the version(s) of the .NET Framework runtime that
          the custom action should run on. If no versions are specified, the chosen version of the runtime
          will be the "best" match to what Microsoft.Deployment.WindowsInstaller.dll was built against.

          WARNING: leaving the version unspecified is dangerous as it introduces a risk of compatibility
          problems with future versions of the .NET Framework runtime. It is highly recommended that you specify
          only the version(s) of the .NET Framework runtime that you have tested against.

          Note for .NET Framework v3.0 and v3.5, the runtime version is still v2.0.

          In order to enable .NET Framework version 2.0 runtime activation policy, which is to load all assemblies 
          by using the latest supported runtime, @useLegacyV2RuntimeActivationPolicy="true".

          For more information, see http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx
        -->

        <supportedRuntime version="v4.0" />
        <supportedRuntime version="v2.0.50727"/>

    </startup>

    <!--
      Add additional configuration settings here. For more information on application config files,
      see http://msdn.microsoft.com/en-us/library/kza1yk3a.aspx
    -->

</configuration>

基本上,允许用CLR2.0/3.0/3.5(所有.NET 2.0 )编写的CA运行4.0是一个很好的做法,因为您可能会遇到一台只安装了4.0的机器。一般来说,你的代码应该可以在4.0下工作,如果它不能工作,我会修复它。

或者,您可以将配置文件更新为只允许在2.0上运行,然后将所需的检查放入安装程序中,以确保实际安装了此版本的CLR。

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11091493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档