Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Installer in .Net showing Form behind installer

[RunInstaller(true)]
public partial class Installer1 : Installer
{
    public Installer1()
    {
        InitializeComponent();
    }

    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
    }
    private void Installer1_AfterInstall(object sender, InstallEventArgs e)
    {
        Form1 topmostForm = new Form1();
        topmostForm.BringToFront();
        topmostForm.TopMost = true;            
        topmostForm.ShowDialog();
  } }

I need to display the topmostForm in front of the default Windows Installer UI. The above is sample code inside my CustomAction that I am using to create a Form. Setting the TopMost property or using ShowDialog is not helping. Is there any other solution to make my form the top most and focussed?

like image 286
Manoj Savalia Avatar asked Jun 02 '11 10:06

Manoj Savalia


People also ask

How do I add installer class to setup project?

To add a custom action click on the custom action icon. This will open the following window and there we can add a project containing an installer class. To create this project having an installer class, we can make a class library type of project and add an installer class in it from the add new item dialog.

How do I create an installer for Windows form application?

If not then Choose View -> Editor -> File System. Now, you need to add output of your Windows Form Application to build the setup. Right-click on the Application Folder and select Add -> Project Output. Leave the default selection of Primary Output in the "Add Project Output Group" dialog box and click the OK button.

How do I create an MSI file in Visual Studio?

Go to Extensions > Manage Extensions > Online > Search, find, download and install Microsoft Visual Studio Installer Projects extension. 2). Add a new Setup Project in your solution > right-click Application Folder > Add > Project Output… > choose the corresponding Project > select Primary output > OK.


4 Answers

If you want to show your own UI in the installer, you won't be able to use a setup and deployment project, because it lacks the features necessary to implement that. Consider using an installer toolkit like WiX or Inno Setup instead.

Concerning the first part of your question, are you passing the custom dialog box in the owner argument to MessageBox.Show()?

like image 132
Frédéric Hamidi Avatar answered Sep 24 '22 02:09

Frédéric Hamidi


although i'm not wuite sure what exactly you're asking for, using WiX for building windows installers is the prefered way to go. There you can build your forms and custom actions and pretty much anything else.

like image 20
Mladen Prajdic Avatar answered Sep 24 '22 02:09

Mladen Prajdic


If you want to have complete control over installer user interface for branding or custom dialogs and don't want to use installer builder software like InstallShield then you can create a C++ application to serve as shell for Windows Installer - there is no need to implement installer actions such as copying files by yourself.

Windows Installer has API for such purpose. With function MsiSetExternalUIRecord you can provide a callback to capture installer notifications such as messages and progress updates.

like image 25
Arunas Avatar answered Sep 23 '22 02:09

Arunas


Dialogs created by custom actions are always displayed behind the installation dialogs on newer Windows versions (Vista and Windows 7). This is because Windows prevents applications to move a window on top of all other windows. Think how virus popups would fill up the screen on older Windows versions.

Instead, a newly created dialog is displayed in the background and it's title bar button (if it has one) flashes.

The correct solution for what you want is creating a dialog in your MSI package and using it instead of the custom action.

like image 35
rmrrm Avatar answered Sep 23 '22 02:09

rmrrm