Question

All, I am trying to add a Custom Action to my VS2010 SetUp Project. What I want to do is showing my custom win-form during the installation. And I want to show the custom win-form as a modal dialog so that the user can't ignore it during the installation.So far I inherit my install class from the System.windows.forms.IWin32Window .But I didn't know how to implement the get member public IntPtr Handle of the interface.

What I have done is below. please help to review it .thanks.

 [RunInstaller(true)]
    public partial class MyInstaller : System.Configuration.Install.Installer,IWin32Window
    {
        public MyInstaller ()
        {
            InitializeComponent();
        }


        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);
        }

        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        protected override void OnAfterInstall(IDictionary savedState)
        {
            base.OnAfterInstall(savedState);

        }


        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);
            Form frm = new frmSelectSource();
            frm.ShowDialog(this);
        }

        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Rollback(IDictionary savedState)
        {
            base.Rollback(savedState);
        }

        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);
        }

        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        protected override void OnCommitted(IDictionary savedState)
        {
            base.OnCommitted(savedState);

        }

        public IntPtr Handle
        {
            get { throw new NotImplementedException(); }
        }
    }

I don't know if it is a right way to make it . If it is wrong or not possible to make it .please kindly to tell me . thanks.

Was it helpful?

Solution

This is one of the many reasons visual studio deployment projects were removed from VS2012. VDPROJ can only schedule custom actions in the deferred phase of the installation execute sequence. This is not an appropriate place to perform user interaction. Windows Installer is designed to perform UI first in the installation user interface sequence and then transfer control to the execute sequence. In a silent installation only the execute sequence is performed.

If you need custom UI you either need to go down a very complicated road of postbuild manipulations of the MSI to inject capabilities not exposed by VDPROJ or switch to a tool such as Windows Installer XML (WiX) of InstallShield Professional Edition that exposes this.

See the following for a better understanding of MSI:

Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top