Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Setup / February 2007

Tip: Looking for answers? Try searching our database.

Gracefully fail an installation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stephajn@gmail.com - 16 Feb 2007 18:31 GMT
I've done all kinds of google searching on this topic, and everyone
seems to say the same thing:

In a Visual Studio Setup package, if I want to fail an installation
based on something found in my custom action code, then I just throw
an InstallException and the runtime will be informed that it must
rollback. The only problem here is that the error message displayed to
the user contains information they don't need to see like the method
name being called, etc.

If I'm going to rollback, I want to be able to display a message box
of my liking to the user in a way they'll understand.  For example,
let's say that I'm installing an application that has a dependency on
Internet Explorer 6 or higher.

I could throw an install exception like this:

throw new InstallException("This application requires you to have
Internet Explorer 6 or higher installed.");

But the display that comes up shows some nastiness in it regarding the
method that threw it and so on.  What I want to do is this:

catch (InstallException instEx)
{
MessageBox.Show(instEx.Message, "Installation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Rollback(savedState);
}

However, what winds up happening is that the Rollback method winds up
throwing its own exception about how the savedState dictionary does
not contain the expected values.  So now what am I supposed to do
exactly?  Do I need to change the savedState dictionary in some way?

Thanks for any help anyone can give on this.
Stephajn
Phil Wilson - 22 Feb 2007 20:48 GMT
The general issue here is that you're using Visual Studio setups and managed
code custom actions. VS setups are not fully featured enough to do what you
want when compared with the other 20 or so tools out there that build MSI
setups. A type 19 custom action is one of the ways you can cause a graceful
termination, but VS setups don't do them. Managed code custom actions have a
lot of infrastructure involving a shim C++ Dll that explicitly loads the CLR
to run your managaed code because MSI does not natively support managed code
custom actions, so you're working within that framework where throwing
InstallException is the way to indicate an error.

Having said that, throwing an InstallException for the wrong version of IE
is rather late in the game. That's what LaunchConditions are for, so if that
IE example is a real one, I'd create a Search Target System that did a file
search for (probably) shdocvw.dll in [SystemFolder] with a minimum version
of 6.0.0, and use the property from the search as a launch condition with
the message "You need at least IE 6.0".

Signature

Phil Wilson
[Microsoft MVP Windows Installer]

> I've done all kinds of google searching on this topic, and everyone
> seems to say the same thing:
[quoted text clipped - 33 lines]
> Thanks for any help anyone can give on this.
> Stephajn

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.