开发者

Problem with shortcut in C# setup project

I have a setup project with a custom installer class which launch the application at the end of the installation. In the setup, I create a shortcut to the output of the application. The installation goes fine. But when I click on the shortcut, the installer restart and the application launch at the same time? Why?

No, the code of my custom class is:

/// <summary>
/// Installer class to automatically launch the application at  the end of the installation/
/// </summary>
[RunInstaller(true)]
public partial class InstallerStartApplication : Installer
{
    /// <summary>
    /// Initializes a new instance of the <see cref="InstallerStartApplication"/> class.
    /// </summary>
    public InstallerStartApplication()
    {            
        InitializeComponent();            
    }

    /// <summary>
    /// Raises the <see cref="E:System.Configuration.Install.Installer.AfterInstall"/> event.
    /// </summary>
    /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state of the computer after all the installers contained in the <see cref="P:System.Configuration.Install.Installer.Installers"/> property have completed their installations.</param>
    protected override void OnAfterInstall(IDictionary savedState)
    {
        base.OnAfterInstall(savedState);


    }

    // Override the 'Install' method.
    public override void Install(IDictionary savedState)
    {
        base.Install(savedState);
    }

    // Override the 'Commit开发者_开发百科' method.
    public override void Commit(IDictionary savedState)
    {           
        base.Commit(savedState);

        try
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            Process.Start(Path.Combine(Directory.GetCurrentDirectory(), "IERssNotificator.exe"), "-c");
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex);
        }  
    }

    // Override the 'Rollback' method.
    public override void Rollback(IDictionary savedState)
    {
        base.Rollback(savedState);
    }


}

I launch this at install and commit custom action.


The setup project places special type of shortcut. It does not simply launch you program. It first checks that all files installed with the program are present. If they do, it launches the program, if they don't installer is run again from msi cache to reinstall missing files.

Do you have post-install actions that delete some of the installed files?


ok, I found the problem. The error is in the code of the custom installer class:

Process.Start(Path.Combine(Directory.GetCurrentDirectory(), "IERssNotificator.exe"), "-c");

This launch a process, not asynchronous and the setup never end. It is why it always restart the setup.

I change my code and laucn the process into a separate thread and so the setup complete.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜