> With AfterInstall I had another problem I didn't found inforamtion how to pass reference to external dll which comes togather with application to AfterInstall
To be entirely accurate you will have this problem regardless of what custom action you are in (ElevatedManagedAction or ManagedSetup event).
The problem is caused by the fact that all MSI CustomActions are sandboxed (isolated) and they are not invoked from the location of your installed files. Thus you have a few options here.
> But it throws ( in deferred custom action )
Sorry. Indeed my reference to "top level try catch" was incorrect. Let's start again but with more details :)
The
Thus as I mentioned you have to preserve the properties you are interested in (in this case REMOVE and INSTALLED) with
Or you can use ManagedProject.AfterInstall event which already does all 'preserving' for you and all SetupEventArgs members are already initialized and set.
To be entirely accurate you will have this problem regardless of what custom action you are in (ElevatedManagedAction or ManagedSetup event).
The problem is caused by the fact that all MSI CustomActions are sandboxed (isolated) and they are not invoked from the location of your installed files. Thus you have a few options here.
- You can either load the assembly dynamically from the INSTALLDIR location
- Or you can ignore the fact that the dependency dll is to be installed and pack it with the Custom Action as well. The simplest way is as follows:
project.DefaultRefAssemblies.Add(@"libraries\Microsoft.Win32.TaskScheduler.dll");
> But it throws ( in deferred custom action )
Sorry. Indeed my reference to "top level try catch" was incorrect. Let's start again but with more details :)
The
IsRepairing
extension method under the hood has an error prevention mechanism that redirects it either to session.Properties
or to sesson.CustomActionData
so you will never hit the 'null' session from the deferred action. However if the property was not preserved into CustomActionData then of course there is not much can be done about it. Thus as I mentioned you have to preserve the properties you are interested in (in this case REMOVE and INSTALLED) with
project.DefaultUsesProperties
.Or you can use ManagedProject.AfterInstall event which already does all 'preserving' for you and all SetupEventArgs members are already initialized and set.