2009-10-26 8 views
0

설치가 끝날 때 응용 프로그램을 시작하는 사용자 지정 설치 관리자 클래스가있는 설치 프로젝트가 있습니다. 설치 과정에서 응용 프로그램 출력에 대한 바로 가기를 만듭니다. 설치가 잘됩니다. 그러나 바로 가기를 클릭하면 설치 프로그램이 다시 시작되고 응용 프로그램이 동시에 시작됩니까? 왜?C# 설치 프로젝트의 바로 가기 문제

아니, 내 사용자 정의 클래스의 코드는 다음과 같습니다

/// <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 설치하고 커밋 사용자 지정 작업에서이 작업을 시작합니다.

답변

1

확인했는데 문제가 발생했습니다. 오류는 사용자 지정 설치 관리자 클래스의 코드에 있습니다.

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

이 프로세스는 비동기 적이 지 않으며 설치가 끝나지 않습니다. 항상 설치를 다시 시작하는 이유입니다.

코드를 변경하고 프로세스를 별도의 스레드로 변경하므로 설정이 완료됩니다.

1

설치 프로젝트는 특별한 유형의 바로 가기를 배치합니다. 단순히 프로그램을 시작하지 않습니다. 먼저 프로그램과 함께 설치된 모든 파일이 있는지 확인합니다. 그럴 경우 설치 프로그램을 msi 캐시에서 다시 실행하여 누락 된 파일을 다시 설치하지 않으면 프로그램을 시작합니다.

설치된 파일 중 일부를 삭제하는 설치 후 작업이 있습니까?

+0

아니요, 내 코드를 참조하십시오 ... 위의 – Coolweb

+0

설치 프로그램을 시작하는 정렬 대신 * 일반 * 바로 가기를 만들 수있는 방법이 있습니까? –

+0

찾지 못했습니다. 마지막으로 WinAPI를 사용하여 커밋 작업에서 바로 가기를 만들었습니다. WScript.Shell 또는 http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp 라이브러리 –