PC Review


Reply
Thread Tools Rate Thread

Windows installer problem

 
 
Lothar Behrens
Guest
Posts: n/a
 
      10th Nov 2010
Hi,

I have written a windows service that could be installed and
uninstalled without problems (including startup of the service). But
when I try to update the components by a newer version the installer
complains about that the service is installed and rolls back.

The installer class looks like this and the last function was my
second attempt to stop the service to avoid a message that an
application must be stopped before updating. This is no problem as I
am doing a silent install.

How to overcome the installed service problem without writing two
different installers?

Is the BeforeInstall handler the right starting point to get rid of
the second problem?
(But probably missing a wait for stopping)

Thanks, Lothar

private void InitializeComponent()
{
this.MonitoringServiceProcessInstaller = new
System.ServiceProcess.ServiceProcessInstaller();
this.MonitoringServiceInstaller = new
System.ServiceProcess.ServiceInstaller();
this.serviceController1 = new
System.ServiceProcess.ServiceController();
//
// MonitoringServiceProcessInstaller
//
this.MonitoringServiceProcessInstaller.Account =
System.ServiceProcess.ServiceAccount.LocalSystem;
this.MonitoringServiceProcessInstaller.Password = null;
this.MonitoringServiceProcessInstaller.Username = null;
//
// MonitoringServiceInstaller
//
this.MonitoringServiceInstaller.ServiceName = "MyService";
this.MonitoringServiceInstaller.StartType =
System.ServiceProcess.ServiceStartMode.Automatic;
//
// serviceController1
//
this.serviceController1.ServiceName = "MyService";
//
// SMCMonitoringInstaller
//
this.Installers.AddRange(new
System.Configuration.Install.Installer[] {
this.MonitoringServiceProcessInstaller,
this.MonitoringServiceInstaller});
this.BeforeUninstall += new
System.Configuration.Install.InstallEventHandler(this.SMCMonitoringInstaller_BeforeUninstall);
this.BeforeInstall += new
System.Configuration.Install.InstallEventHandler(this.SMCMonitoringInstaller_BeforeInstall);
this.AfterInstall += new
System.Configuration.Install.InstallEventHandler(this.SMCMonitoringInstaller_AfterInstall);

}

private void SMCMonitoringInstaller_AfterInstall(object
sender, InstallEventArgs e)
{
serviceController1.Start();
}

private void SMCMonitoringInstaller_BeforeUninstall(object
sender, InstallEventArgs e)
{
serviceController1.Stop();
}

private void SMCMonitoringInstaller_BeforeInstall(object
sender, InstallEventArgs e)
{
try
{
serviceController1.Stop();
}
catch
{

}
}
 
Reply With Quote
 
 
 
 
r norman
Guest
Posts: n/a
 
      10th Nov 2010
On Wed, 10 Nov 2010 06:59:35 -0800 (PST), Lothar Behrens
<(E-Mail Removed)> wrote:

>Hi,
>
>I have written a windows service that could be installed and
>uninstalled without problems (including startup of the service). But
>when I try to update the components by a newer version the installer
>complains about that the service is installed and rolls back.
>
>The installer class looks like this and the last function was my
>second attempt to stop the service to avoid a message that an
>application must be stopped before updating. This is no problem as I
>am doing a silent install.
>
>How to overcome the installed service problem without writing two
>different installers?
>
>Is the BeforeInstall handler the right starting point to get rid of
>the second problem?
>(But probably missing a wait for stopping)
>
>Thanks, Lothar
>
> private void InitializeComponent()
> {
> this.MonitoringServiceProcessInstaller = new
>System.ServiceProcess.ServiceProcessInstaller();
> this.MonitoringServiceInstaller = new
>System.ServiceProcess.ServiceInstaller();
> this.serviceController1 = new
>System.ServiceProcess.ServiceController();
> //
> // MonitoringServiceProcessInstaller
> //
> this.MonitoringServiceProcessInstaller.Account =
>System.ServiceProcess.ServiceAccount.LocalSystem;
> this.MonitoringServiceProcessInstaller.Password = null;
> this.MonitoringServiceProcessInstaller.Username = null;
> //
> // MonitoringServiceInstaller
> //
> this.MonitoringServiceInstaller.ServiceName = "MyService";
> this.MonitoringServiceInstaller.StartType =
>System.ServiceProcess.ServiceStartMode.Automatic;
> //
> // serviceController1
> //
> this.serviceController1.ServiceName = "MyService";
> //
> // SMCMonitoringInstaller
> //
> this.Installers.AddRange(new
>System.Configuration.Install.Installer[] {
> this.MonitoringServiceProcessInstaller,
> this.MonitoringServiceInstaller});
> this.BeforeUninstall += new
>System.Configuration.Install.InstallEventHandler(this.SMCMonitoringInstaller_BeforeUninstall);
> this.BeforeInstall += new
>System.Configuration.Install.InstallEventHandler(this.SMCMonitoringInstaller_BeforeInstall);
> this.AfterInstall += new
>System.Configuration.Install.InstallEventHandler(this.SMCMonitoringInstaller_AfterInstall);
>
> }
>
> private void SMCMonitoringInstaller_AfterInstall(object
>sender, InstallEventArgs e)
> {
> serviceController1.Start();
> }
>
> private void SMCMonitoringInstaller_BeforeUninstall(object
>sender, InstallEventArgs e)
> {
> serviceController1.Stop();
> }
>
> private void SMCMonitoringInstaller_BeforeInstall(object
>sender, InstallEventArgs e)
> {
> try
> {
> serviceController1.Stop();
> }
> catch
> {
>
> }
> }



What if you try uninstalling the older service, not just stopping it?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Installer version 1.0 to Windows Installer version 1.1. jw Windows XP General 2 9th Jan 2006 06:38 PM
Windows Installer version 1.0 to Windows Installer version 1.1 jw Windows XP Basics 1 9th Jan 2006 06:34 PM
Windows Installer version 1.0 to Windows Installer version 1.1 jw Windows XP Help 0 9th Jan 2006 03:31 PM
June's Windows Installer Chat on MSDN: Using the Windows Installer with the Driver Install Frameworks Tools (DIFXApp) Tyler Robinson [MSFT] Microsoft Windows 2000 MSI 0 15th Jun 2005 12:20 AM
Please advise a good Windows Installer book in addition to "VB/VBA Developer's Guide to the Windows Installer" Maxim Masiutin Microsoft Windows 2000 MSI 3 11th Apr 2004 12:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:51 PM.