I have got problem with custom actions in my project. Some are working, some not. I have got two projects C# CustomAction Project and Setup Project in VS 2012. My custom actions look like this. The two first actions are not causing the problem. Only the third one is not working.
[CustomAction]
public static ActionResult WriteToConfigStore(Session session)
{
...
}
[CustomAction]
public static ActionResult CleanConfigStore(Session session)
{
...
}
[CustomAction]
public static ActionResult CheckPrograms(Session session)
{
string s = "";
Process[] p = Process.GetProcesses();
foreach (Process ps in p)
{
s += ps.ProcessName + ";";
}
MessageBox.Show(s);
return ActionResult.Success;
}
I defining custom actions like this:
<Binary Id="CustomActionsId" SourceFile="$(var.ResourcesDir)\DriverCA.CA.dll" />
<CustomAction Id="ca_writeToConfigStoreId" BinaryKey="CustomActionsId" DllEntry="WriteToConfigStore" Execute="deferred" Return="check" />
<CustomAction Id="ca_cleanConfigStoreId" BinaryKey="CustomActionsId" DllEntry="CleanConfigStore" Execute="deferred" Return="check" />
<CustomAction Id="ca_setParameter" Return="check" Property="ca_writeToConfigStoreId" Value="param1=.;param2=;param3=;param4=;param5=IviDriver1.0, IviSwtch1.0" />
<CustomAction Id="ca_setCleanParameter" Return="check" Property="ca_cleanConfigStoreId" Value="param1=;" />
<CustomAction Id="ca_checkProgramsId" BinaryKey="CustomActionsId" DllEntry="CheckPrograms" Execute="deferred" Return="check" />
My install sequence is looking like this:
<InstallExecuteSequence>
<Custom Action="ca_setParameter" Before="InstallFinalize" />
<Custom Action="ca_setCleanParameter" Before="InstallFinalize" />
<!--Call only when not uninstall (install, change, repair)-->
<Custom Action="ca_writeToConfigStoreId" After="ca_setParameter">NOT(REMOVE="ALL")</Custom>
<!--Call only when uninstall or upgrade-->
<Custom Action="ca_cleanConfigStoreId" After="ca_setCleanParameter">REMOVE="ALL"</Custom>
<!--Call only when not install-->
<Custom Action="ca_checkProgramsId" After="MsiUnpublishAssemblies">Installed</Custom>
</InstallExecuteSequence>
When I comment <Custom Action="ca_checkProgramsId" After="MsiUnpublishAssemblies">Installed</Custom>
everything works fine. But when this part is not commented out, then I got error There is problem with this Windows Installer package. A DLL required for this install to complete could not be run.
when uninstalling the program. I can't see any error. Every name and ID are correct. I am not using PInvoke or anything like that.
UPDATE: The goal of custom action is to check if some processes are running or not and interrup uninstall process according to it. Setup is per system and I didn't have problem problem with message boxes in any other custom actions. I solved it with another custom action project that have problem custom action in it by itself, but otherwise I am using exactly same methods and setup definitions (excluding another dll definition of course) Still don't know what the problem is.