cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vnikolov
Level 3

Rollback after failed self register.

Hi all,
I have a self register dll.
The roll back is not triggered if the registration fails.
Is there a way to trigger rollback on registration failure?

Regards
Vlad
Labels (1)
0 Kudos
(12) Replies
RobertDickau
Flexera Alumni

How are you registering the DLL? Better yet, is there a way to avoid the registration failing? (In what way does it fail?)
0 Kudos
vnikolov
Level 3

Hi,
I am using self register method on BasicMSI project.
It was failing because of one missing dll in the package.
It is fixed now, but what if self-register fails for some other reason?
Isn't it better to rollback the installation? It will not be functional application if the registration is failed, so IMO it should be rollbacked, correct?
Regards
Vlad
0 Kudos
Christopher_Pai
Level 16

It's better to not use self registration in the first place. It's a legacy anti-pattern that isn't a best practice.

Think about it for a moment. Instead of using data driven standard actions that richly describe the exact registration requirements, your trusting fragile third party, out of process code to do the job. Windows Installer has no idea what this code is going to do. If this code fails, just how do you expect MSI to clean it up? Call DllUnRegisterServer() and hope that doesn't fail also? And let's say a previous component had been installed and you want to get it's registration data back. Hope the the new controls DllRegisterServer() will handle this also?

It's all crap and there's a reason that you should use the COM/Registry tables instead of doing SelfReg.

Or better yet, stop using COM altogether. 🙂
0 Kudos
vnikolov
Level 3

Hi,
Thanks, sounds reasonable.
So what is the proper way to register dll-s?

Regards
Vlad
0 Kudos
RobertDickau
Flexera Alumni

Please see the help topics under Creating Installations > Organizing Files... > Registering COM Servers to learn more about your options.
0 Kudos
loralynne
Level 6

Another option is to create a custom action that launches an executable and for the Filename & Command line value, enter

regsvr32.exe /s "[PATH_TO_FILE]fileToRegister.dll"

The /s option makes it silent, suppressing any message boxes.
0 Kudos
RobertDickau
Flexera Alumni

For the reasons Chris mentions (no rollback or uninstall, possible trouble with dependencies, and more), using regsvr32.exe falls into the bin of last-resort registration techniques. There's even an InstallShield best practice rule (ISBP12) that will show a warning if an action appears to use regsvr32...
0 Kudos
loralynne
Level 6

Thanks for the info, Robert. I actually have tried to use COM extraction in the past, but it didn't quite work for me because of a sequencing or race condition or something. So I have the following CAs in my project:

1. a deferred CA that calls regsvr32
2. a corresponding rollback CA for #1 that runs regsvr32 with the /u flag to unregister it
3. a deferred CA that calls regsvr32.exe with the /u flag during uninstallation
4. a corresponding rollback CA for #3 that runs regsvr32 to register it
0 Kudos
RobertDickau
Flexera Alumni

Fair enough, but in the fullness of time figuring why the COM extraction doesn't work might be worthwhile. (The features are a bit more obscure/reviled, but using regsvr32 also doesn't play well with MSI advertisement, per-user or -machine registration, relative paths, ...) Was there an error, or did extraction just freeze, or ...?
0 Kudos
loralynne
Level 6

Yes, I would much rather use COM extraction over regsvr32. It's been over a year since I last tried using COM extraction (again), but the error wasn't during the extraction which worked fine, rather during installation and/or installation of the product. I was looking through my version control logs, and the two times that I switched to using COM extraction resulted in problems using our product (during our development cycle), so I reverted back to using regsvr32 both times. I'll have to take a more in-depth look at it at some point.

Thanks again, Robert.
0 Kudos
vnikolov
Level 3

Thanks all,
finaly I used two custom actions:

RegisterAddin
# Name: RegisterAddin
# DLL Keyfile: Adxloader
# Function Signature: (Name: DllRegister, Type: HANDLE, Source: Constant, Value: MsiHandle, Return Value: Void) # Inscript Execution: Deferred # Install Execute Sequence: AfterSelfRegModules # Install Exec Condition: Not Installed

UnregisterAddin
# Name: UnregisterAddin
# DLL Keyfile: Adxloader
# Function Signature: (Name: DllUnregister, Type: HANDLE, Source: Constant, Value: MsiHandle, Return Value: Void) # Inscript Execution: Immediate Execution # Install Execute Sequence: AfterSelfRUnegModules # Install Exec Condition: Installed
0 Kudos
Christopher_Pai
Level 16

Good luck with that.
0 Kudos