Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WIX CustomAction加载CLR 4.0而不是2.0_Wix_Custom Action_Dtf - Fatal编程技术网

WIX CustomAction加载CLR 4.0而不是2.0

WIX CustomAction加载CLR 4.0而不是2.0,wix,custom-action,dtf,Wix,Custom Action,Dtf,我正在尝试编写一个c#自定义操作并使用.NET2,但是我似乎无法让它正常工作。我相信MSI使用了错误的CLR版本。我在MSI调用我的CA的日志文件的上面几行看到了这一点(如果我注释掉我的CA,则不会出现第行): 我的自定义操作似乎没有加载(假设我没有看到任何日志消息)。我正在使用Wiz 3.6.3014.0。这是受支持的,还是Windows安装程序只使用计算机上可用的最新运行时 谢谢当您使用WiX创建一个C#自定义操作项目时,默认情况下它会创建一个名为CustomAction.config的XM

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

我的自定义操作似乎没有加载(假设我没有看到任何日志消息)。我正在使用Wiz 3.6.3014.0。这是受支持的,还是Windows安装程序只使用计算机上可用的最新运行时


谢谢

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

<?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>

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


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

可能重复我尝试删除该行,但是它仍然使用.Net 4。关键是如下设置配置文件:我认为这是您最初在VS2008中创建项目并随后将其更新为VS2010时得到的结果。尽管如此,我对此并不乐观。@ChristopherPaint我可以确认我的设置是这样的-我将建议的行添加到customaction.config文件中,但它仍然不起作用;我目前正在使用vs2012,但wix项目和自定义操作项目最初都是在vs2008中创建的,因此我在vs2012中从头开始重新创建了自定义操作项目,并更新了我的wix项目以引用新的CA项目,现在一切正常。您是否比较了之前和之后的.csproj以了解有什么不同?
<?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>