skizzle
Posts: 9
Joined: Mon May 23, 2011 11:13 pm

Invoking a Rollback

Is it possible to invoke a rollback myself? I have a custom action exe (writting in vb.net) that I run that performs database maintenance (ie adding tables, columns, etc) on a database installed on the user's computer. This custom action will be used primarily during Uninstall/Reinstall operations. If this custom action fails I want the install to stop and throw an error, then rollback any work that was done. I've tried putting the custom action in the Uninstall, Install, and Remove Files sequences, but it never seems to work as designed when I the custom action fails. I also have a rollback custom action that I want to run to UNDO any database maintenance actions that occurred. I've tried setting Environment.ExitCode = 1603 in my exe, but AI seems to ignore it. I DO have "Synchronous executing, check return code" set on the custom action. Any help you could give me on this problem would be greatly appreciated. I'm almost completed with the installer project but I've got this one piece left. I'm out of ideas.

Thanks,

Scott
skizzle
Posts: 9
Joined: Mon May 23, 2011 11:13 pm

Re: Invoking a Rollback

I'm going to give a better explanation of what I'm trying to accomplish and maybe that will better help you help me.

I've got an application that is using SQL CE (.sdf) database files in it. These databases are synchronized with a central database using MS Sync Services. When we change our table structure (ie add new table, add column, etc) on the central database we need to get those changes made on the Compact DB's also. To do this, I've got a separate sql updater exe that is included with the install that takes care of this. These database changes will only be made during an Uninstall/Reinstall (Upgrade). In order for my sql updater exe to work it needs the "current version" of the program, so because of that I've been running this during the uninstall sequence (before the files (sql updater exe and app exe) are removed). NOTE: The sdf files are marked as "Never Overwrite". I have an inline custom action that runs before the sql updater exe that gets the current version of my app's exe. I then use that property value to pass into my sql updater exe. That whole process runs fine. However, in the event that my sql updater.exe fails, I need some kind of fail-safe that will stop the install and rollback. If my sql updater exe fails while running in the Uninstall sequence, I want the uninstall to rollback and then NOT install the new version (I cannot get this to work). My sql updater exe is written in vb.net. I'm using Environment.ExitCode = 0 for success and Environment.ExitCode = 1603 if it fails. However, that ExitCode does not seem to effect the running of AI at all. If you could give me some insight into this I would greatly appreciate it. I've read all the help docs but have yet to find something about this.

Thanks again for your help.
Scott
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Invoking a Rollback

Hi Scott,

You can try to use the "Error Message" custom action to show an error and initiate a rollback. Here is its user guide reference.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
skizzle
Posts: 9
Joined: Mon May 23, 2011 11:13 pm

Re: Invoking a Rollback

How I do I know when to show that error message? "Error Message" is only enabled in the install finalize sequence. I don't know if my program has errored because I cannot check my return code of my application from AI? Let me ask you this, what does "Synchronous executing, check return code" mean? I know what the synchronous part means, but doesn't the second part mean that AI will check my custom action exe for a return code of 0 and then error if it receives a return code other than 0? I would think that's what it should do.

Thanks,
Scott
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Invoking a Rollback

Hi Scott,

Here is a similar thread that explains how to do this directly from a .NET custom action.
How I do I know when to show that error message? "Error Message" is only enabled in the install finalize sequence.
Actually you can show an error message after any standard action except the default ones. However this would require you somehow assign an installer public property from within your custom action and use it as a condition.
I don't know if my program has errored because I cannot check my return code of my application from AI? Let me ask you this, what does "Synchronous executing, check return code" mean?
You would also need to set your custom action with this execution property in order for it to check the return code and initiate a rollback. For more information about "Synchronous executing, check return code" here is the user guide reference.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Invoking a Rollback

Reposting article for user guypb, lost due to hardware changes on our servers.
skizzle wrote:I've got an application that is using SQL CE (.sdf) database files in it. These databases are synchronized with a central database using MS Sync Services. When we change our table structure (ie add new table, add column, etc) on the central database we need to get those changes made on the Compact DB's also. To do this, I've got a separate sql updater exe that is included with the install that takes care of this. These database changes will only be made during an Uninstall/Reinstall (Upgrade). In order for my sql updater exe to work it needs the "current version" of the program, so because of that I've been running this during the uninstall sequence (before the files (sql updater exe and app exe) are removed). NOTE: The sdf files are marked as "Never Overwrite". I have an inline custom action that runs before the sql updater exe that gets the current version of my app's exe. I then use that property value to pass into my sql updater exe. That whole process runs fine. However, in the event that my sql updater.exe fails, I need some kind of fail-safe that will stop the install and rollback. If my sql updater exe fails while running in the Uninstall sequence, I want the uninstall to rollback and then NOT install the new version (I cannot get this to work). My sql updater exe is written in vb.net. I'm using Environment.ExitCode = 0 for success and Environment.ExitCode = 1603 if it fails. However, that ExitCode does not seem to effect the running of AI at all. If you could give me some insight into this I would greatly appreciate it. I've read all the help docs but have yet to find something about this.
I need to add a column to an existing sdf table as part of an update or uninstall/reinstall as above - not sure where to start - any ideas? My current sdf file is also set to "PERMANENT" & "NEVER OVERWRITE".

Return to “Common Problems”