Installer class oddities

G

Guest

I have a C# service where I have included a ProjectInstaller class to handle
the installation. I experiance a number of oddities, and I don't know if I'm
doing anything wrong, or if the Installer class is behaving odd.

1. I added code in the Committed event handler to start the service. It
never ran. I added code to *all* events in order to track what events that
was fired. Only the BeforeUninstall, AfterUninstall, BeforeInstall and
AfterInstall was activated. Why didn't I get any of the other events?

2. I tried to override the Install, Commit and Rollback methods just in case
I really needed to do that (the Install class documentation isn't clear on if
that is a requirement or not). Only the Install method is called, none of the
other.

OK, I went on and placed my service start code in the AfterInstall event
since that is always fired, then I noticed another problem:

My project is configured to automatically uninstall any previous version
before installing the new one. I presumed that the Uninstall methods from the
*old* version would be used when uninstalling the old version, and that the
Install methods from the *new* version would be used when installing the new
version. This is not the case.

Whenever I upgrade my project, the *old* ProjectInstaller class is used for
both the uninstall and the install!? The effect is that I will *always*
install the new version with the ProjectInstaller class from the old version.
In my oppinion, this is illogical, stupid and dangerous.

Am I doing something wrong here, or is this "expected" behaviour from the
ProjectInstaller class?
 
G

Guest

To do what? I only added som tracking code to the events of the
ProjectInstaller class...
 
J

John Vottero

Scewbedew said:
I have a C# service where I have included a ProjectInstaller class to
handle
the installation. I experiance a number of oddities, and I don't know if
I'm
doing anything wrong, or if the Installer class is behaving odd.

1. I added code in the Committed event handler to start the service. It
never ran. I added code to *all* events in order to track what events that
was fired. Only the BeforeUninstall, AfterUninstall, BeforeInstall and
AfterInstall was activated. Why didn't I get any of the other events?

2. I tried to override the Install, Commit and Rollback methods just in
case
I really needed to do that (the Install class documentation isn't clear on
if
that is a requirement or not). Only the Install method is called, none of
the
other.

OK, I went on and placed my service start code in the AfterInstall event
since that is always fired, then I noticed another problem:

My project is configured to automatically uninstall any previous version
before installing the new one. I presumed that the Uninstall methods from
the
*old* version would be used when uninstalling the old version, and that
the
Install methods from the *new* version would be used when installing the
new
version. This is not the case.

Whenever I upgrade my project, the *old* ProjectInstaller class is used
for
both the uninstall and the install!? The effect is that I will *always*
install the new version with the ProjectInstaller class from the old
version.
In my oppinion, this is illogical, stupid and dangerous.

Am I doing something wrong here, or is this "expected" behaviour from the
ProjectInstaller class?

Yep, it's broken. One workaround is to use two Installer classes in two
different assemblies. Put the uninstall stuff in one assembly and the
install stuff in the other assembly.

The best fix is to eliminate the Installer based classes and create an MSI
with something like WiX (see wix.sourceforge.net)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top