[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.setup

Clean rollback installation in the Install method (System.Configuration.Install

M-A Boivin

3/6/2007 11:36:00 PM

I use a Deployment Project in Visual Studio 2005. I added a custom
action class that extends System.Configuration.Install.Installer. In
the method "Install", i check that all my dependencies are met so I
can continue the normal installation process. I can't use the launch
conditions because I need to check several values in the registry (not
only if it exists) like the version. I'd like to know if it's
possible to "correctly" rollback the installation.

Here's a short snippet of my method:

public override void Install(System.Collections.IDictionary
stateSaver)
{
base.Install(stateSaver);

bool lRequirementsNotMet = false;
RegistryKey lRegistryKey = Registry.LocalMachine;
//(...)
lRequirementsNotMet = true;

if (lRequirementsNotMet)
{
//I tried base.Rollback(stateSaver);
throw new InstallException("Requirements not met!");
}
}

The problem is, in Windows XP, the setup displays a window with my
message inside and that is correct, and then rollbacks the
installation (what I want to do).
In Windows Vista, i get a message saying "The installer has
encountered an unexpeted error installing this package. This may
indicate a problem with this package. The error code is 2869." and
then rollbacks. I run the install as an administrator. I expected to
see the same message as in Windows XP.

Is there a way to correctly rollback an installation based on
requirements? Do I absolutely need to throw an InstallException or is
there a best way to do it? Any suggestion or best practices are
welcome.

1 Answer

Phil Wilson

3/7/2007 6:48:00 PM

0

See the thread in this group "Gracefully fail an installation" starting
2/16/2007.

IMO you're using the wrong tool. You're installing the entire product before
detecting missing prerequisites and rolling back. The general problem is
that Visual Studio setups don't let you add custom action code before the
launch conditions, otherwise you'd do the detection much earlier and the
setup wouldn't even start. The other issue is that you're using managed code
custom actions, and InstallExceptions are how that works. C++ custom actions
have more flexibility.

So unfortunately you can't use best practices because Visual Studio setups
don't supply them. That's the reason there are products out there from Wise,
InstallShield, Advanced Installer, Wix and so on that give you access to all
the features of Windows Installer.

--
Phil Wilson
[Microsoft MVP - Windows Installer]

"M-A Boivin" <maboivin@gmail.com> wrote in message
news:1173224163.414909.103480@t69g2000cwt.googlegroups.com...
>I use a Deployment Project in Visual Studio 2005. I added a custom
> action class that extends System.Configuration.Install.Installer. In
> the method "Install", i check that all my dependencies are met so I
> can continue the normal installation process. I can't use the launch
> conditions because I need to check several values in the registry (not
> only if it exists) like the version. I'd like to know if it's
> possible to "correctly" rollback the installation.
>
> Here's a short snippet of my method:
>
> public override void Install(System.Collections.IDictionary
> stateSaver)
> {
> base.Install(stateSaver);
>
> bool lRequirementsNotMet = false;
> RegistryKey lRegistryKey = Registry.LocalMachine;
> //(...)
> lRequirementsNotMet = true;
>
> if (lRequirementsNotMet)
> {
> //I tried base.Rollback(stateSaver);
> throw new InstallException("Requirements not met!");
> }
> }
>
> The problem is, in Windows XP, the setup displays a window with my
> message inside and that is correct, and then rollbacks the
> installation (what I want to do).
> In Windows Vista, i get a message saying "The installer has
> encountered an unexpeted error installing this package. This may
> indicate a problem with this package. The error code is 2869." and
> then rollbacks. I run the install as an administrator. I expected to
> see the same message as in Windows XP.
>
> Is there a way to correctly rollback an installation based on
> requirements? Do I absolutely need to throw an InstallException or is
> there a best way to do it? Any suggestion or best practices are
> welcome.
>