【问题标题】:Simple WiX Custom Action in Custom UI Ends Prematurely自定义 UI 中的简单 WiX 自定义操作提前结束
【发布时间】:2013-09-20 15:13:23
【问题描述】:

使用 Visual Studio 2012、WiX 3.7,当我尝试在我的 自定义 UI 中执行 自定义操作 以验证产品密钥输入时,安装程​​序只需转到“安装向导提前结束”对话框并强制您退出(不会抛出错误消息),无论在产品密钥输入中输入什么。

我关注的指南是http://www.schiffhauer.com/downloads/WiX-Walkthrough.pdf

我已经在启用日志记录的情况下运行了 .msi,但我仍然看不出有什么问题。我在下面包含了我认为所有相关信息,如果您需要更多信息,请告诉我。 我不确定如何在 Visual Studio 中调试它,CustomAction 中的 System.Diagnostics.Debugger.Launch(); 似乎没有做任何事情。我能够通过 http://www.davidmoore.info/2010/06/28/how-to-debug-a-windows-installer-custom-action/ 进行调试,但即使当设置断点VS只是说msiexec.exe has triggered a breakpointSource Not Available

UI.wxs:

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
  <!-- ValidateProductID using CustomAction 'LicenseCheckAction' -->
  <Publish Event="DoAction" Value="LicenseCheckAction">1</Publish>
  <Publish Event="SpawnDialog" Value="InvalidPidDlg">PIDACCEPTED = "0"</Publish>
  <Publish Event="NewDialog" Value="InstallDirDlg">PIDACCEPTED = "1"</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
  <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>

产品.wxs:

<Binary Id="LicenseCheckDLL" SourceFile="..\LicenseCheck\bin\$(var.MyProj.Configuration)\LicenseCheck.CA.dll" />
<CustomAction Id="LicenseCheckAction" BinaryKey="LicenseCheckDLL" DllEntry="LicenseCheck" />
<UIRef Id="$(var.ProductName)_UI" />

自定义操作:

public class CustomActions
{
    [CustomAction]
    public static ActionResult LicenseCheck(Session session)
    {
        try
        {
            session.Log("Begin LicenseCheck");
            string Pid = session["PIDKEY"];
            session["PIDACCEPTED"] = Pid.StartsWith("1") ? "1" : "0";
        }
        catch (Exception ex)
        {
            session.Log("ERROR Caught in custom action: {0}", ex.ToString());
            return ActionResult.Failure;
        }
        return ActionResult.Success;
    }
}

日志:

Action 10:57:04: LicenseAgreementDlg. Dialog created
MSI (c) (A4:64) [10:57:05:863]: PROPERTY CHANGE: Adding LicenseAccepted property. Its value is '1'.
Action 10:57:06: LicenseKeyDlg. Dialog created
MSI (c) (A4:64) [10:57:07:017]: PROPERTY CHANGE: Adding PIDKEY property. Its value is '**********'.
MSI (c) (A4:64) [10:57:21:142]: PROPERTY CHANGE: Modifying PIDKEY property. Its current value is '**********'. Its new value: '**********'.
MSI (c) (A4:64) [10:57:21:215]: Doing action: LicenseCheckAction
Action 10:57:21: LicenseCheckAction. 
Action start 10:57:21: LicenseCheckAction.
MSI (c) (A4:64) [10:57:21:239]: Creating MSIHANDLE (1) of type 790542 for thread 6756
MSI (c) (A4:EC) [10:57:21:240]: Invoking remote custom action. DLL: C:\Users\dirt\AppData\Local\Temp\MSI2AEF.tmp, Entrypoint: LicenseCheck
MSI (c) (A4:58) [10:57:21:241]: Cloaking enabled.
MSI (c) (A4:58) [10:57:21:241]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (A4:58) [10:57:21:241]: Connected to service for CA interface.
MSI (c) (A4!A4) [10:57:21:280]: Creating MSIHANDLE (2) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:280]: Closing MSIHANDLE (2) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:300]: Creating MSIHANDLE (3) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:300]: Closing MSIHANDLE (3) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:331]: Creating MSIHANDLE (4) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:333]: Closing MSIHANDLE (4) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:335]: Creating MSIHANDLE (5) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:335]: Closing MSIHANDLE (5) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:336]: Creating MSIHANDLE (6) of type 790531 for thread 9892
MSI (c) (A4!A4) [10:57:21:337]: Closing MSIHANDLE (6) of type 790531 for thread 9892
MSI (c) (A4:EC) [10:57:21:341]: Closing MSIHANDLE (1) of type 790542 for thread 6756
Action ended 10:57:21: LicenseCheckAction. Return value 3.
DEBUG: Error 2896:  Executing action LicenseCheckActionfailed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: LicenseCheckAction, , 
Action ended 10:57:21: WelcomeDlg. Return value 3.
MSI (c) (A4:50) [10:57:21:343]: Doing action: FatalError
Action 10:57:21: FatalError. 
Action start 10:57:21: FatalError.
Action 10:57:21: FatalError. Dialog created
Action ended 10:57:23: FatalError. Return value 2.
Action ended 10:57:23: INSTALL. Return value 3.
MSI (c) (A4:50) [10:57:23:556]: Destroying RemoteAPI object.
MSI (c) (A4:58) [10:57:23:556]: Custom Action Manager thread ending.

【问题讨论】:

    标签: wix


    【解决方案1】:

    我注意到指南没有提到 CustomAction.config 文件。这是我使用的:

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

    如果您还没有找到它,相关文档位于 %ProgramFiles(x86)%\WiX Toolset v3.7\doc\DTF.chm。

    【讨论】:

    • 伙计,我在某处看到有人提到您必须使用 CustomAction.config 作为文件名,但我认为那是 bologna 。将我的默认LicenseCheck.config 重命名为CustomAction.config 后,它可以工作了!!!!!!谢谢!
    • @dirt 既然你提到了它,我想我在编写我的第一个 C# 自定义操作时也被绊倒了。
    猜你喜欢
    • 2018-10-19
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多