6

I have an installer which has a custom screen containing a button. When that button is pressed, a Custom Action must run which verifies a few things, and returns success or an error.

I have my button defined as follows:

<Control Type="PushButton" Id="DatabaseVerifyConnectionButton" X="118" Y="150" Width="116" Height="17" Text="Verify Connection" Property="DATABASEVERIFYCONNECTIONBUTTONPROPERTY" Default="yes">
    <Publish Event="DoAction" Value="VerifyDatabaseConnection">1</Publish>
    <Publish Event="SpawnDialog" Value="VerifySuccessDlg">VERIFIEDCONNECTION = "1"</Publish>
    <Publish Event="SpawnDialog" Value="VerifyFailedDlg">VERIFIEDCONNECTION = "0"</Publish>
</Control>

My Custom Action XML

<CustomAction Id="VerifyDatabaseConnectionCA"
                BinaryKey="DatabaseCustomAction.CA.dll"
                DllEntry="VerifyDatabaseConnection2"
                Execute="immediate"
                Return="check"/>

<CustomAction Id='VerifyDatabaseConnection'
    Property='VerifyDatabaseConnectionCA'
    Execute='immediate'
    Value="ServerIP=[DATABASESERVERIPTEXTBOXPROPERTY];Username=[DATABASEUSERNAMETEXTBOXPROPERTY];Password=[DATABASEPASSWORDTEXTBOXPROPERTY]"/>

My Custom Action C# code:

    [CustomAction]
    public static ActionResult VerifyDatabaseConnection(Session session)
    {
        System.Diagnostics.Process.Start(@"C:\Windows\System32\calc.exe");

        return ActionResult.Failure;
    }

The logs show the following:

MSI (c) (58:B4) [16:39:45:183]: Doing action: VerifyDatabaseConnection
Action 16:39:45: VerifyDatabaseConnection. 
Action start 16:39:45: VerifyDatabaseConnection.
Action ended 16:39:45: VerifyDatabaseConnection. Return value 1.

I have tried a lot of things. Attaching a debugger, doesn't work. Returning success or failure, doesn't seem to matter anything. Heck, it doesn't even start up the calculator when you click the button. I did notice that changing the entry point for the custom action didn't seem to matter at all.

I also read something about MakeSfxCA.exe, but I couldn't for the life of me find ANYWHERE on how to make it work properly. But I also read that Visual Studio should do it for you if you added the Custom Action project as a Custom Action Project, which I did.

I'm at a complete loss here. Why won't this work? It shows success everywhere but it just does not execute any code at all.

Wotuu
  • 828
  • 1
  • 8
  • 18

1 Answers1

1
<CustomAction Id="VerifyDatabaseConnectionCA"
                    BinaryKey="DatabaseCustomAction.CA.dll"
                    DllEntry="VerifyDatabaseConnection2"
                    Execute="immediate"
                    Return="check"/>

Check you DLLEntry name "VerifyDatabaseConnection2" but you actual custom action method name is "VerifyDatabaseConnection" (2 is missing, so that was never getting called").

Also change the publish element to call "VerifyDatabaseConnectionCA" instead of "VerifyDatabaseConnection".

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56
  • 1
    Good eye, but that was the test I did to check if it made a compiler error if the DllEntry was wrong. It didn't, rest assured that nothing happens when the 2 is removed :) – Wotuu Jan 30 '14 at 21:10
  • 1
    Can you change that publish element to call "VerifyDatabaseConnectionCA" instead of "VerifyDatabaseConnection"? – Isaiah4110 Jan 30 '14 at 22:17
  • OK changing that does indeed open the calculator. I'll see around why it doesn't work the way I had it and how I can change parameters in another way from the Custom Action. Will report, thanks so far! Makes my day bearable. – Wotuu Jan 31 '14 at 08:50
  • Adjusting properties through session[""] actually works now! Thanks a lot for the help! If you can write an answer which says above I'll accept it as the answer. – Wotuu Jan 31 '14 at 08:59