2016-08-29 34 views
0

我使用此代碼(產品節點內所定義的)的.NET Framwork推出一個簡單的自定義動作維克斯無法啓動自定義動作與4

<!-- Run as admin --> 
<Property Id="Privileged" Value="1" /> 
<!-- .NET Framework must be 4.6--> 
<PropertyRef Id="WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED" /> 
<Condition Message="You must install Microsoft .NET Framework 4.6 or higher."> 
    <![CDATA[Installed OR WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED]]> 
</Condition> 

<Binary Id="Ctav8.CustomAction.CA.dll" 
     SourceFile="$(var.Ctav8.CustomAction.TargetDir)Ctav8.CustomAction.CA.dll" /> 

<CustomAction Id="CustomAction1" 
       Return="check" 
       Execute="immediate" 
       BinaryKey="Ctav8.CustomAction.CA.dll" 
       DllEntry="CustomAction1" /> 

<InstallExecuteSequence> 
    <Custom Action="CustomAction1" After="InstallFiles" /> 
</InstallExecuteSequence> 

並且這與它的配置的簡單的自定義動作

public class CustomActions 
{ 
    [CustomAction] 
    public static ActionResult CustomAction1(Session session) 
    { 
     session.Message(InstallMessage.Warning, new Record 
     { 
      FormatString = "test" 
     }); 

     return ActionResult.Success; 
    } 
} 

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true">  
     <supportedRuntime version="v2.0.50727"/> 
     <supportedRuntime version="v4.0"/> 
    </startup> 
</configuration> 

注意:配置文件被稱爲'CustomAction.config',其生成操作被設置爲'內容'。我嘗試將'useLegacyV2RuntimeActivationPolicy'設置爲true和false,但結果仍然相同。

如果我將自定義操作項目的.NET Framework更改爲3.5,此代碼正常工作。

怎麼了?

感謝

回答

0

我CustomAction的配置看起來像這樣

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

而且它與目標.NET 4.5的作品。也許你只需要翻轉supportedRuntime標籤。

0

我解決了使用

<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
     <supportedRuntime version="v4.0"/> 
    </startup> 
</configuration> 

這適用於.NET框架4.6.1