【发布时间】:2015-01-14 14:28:49
【问题描述】:
我的项目中的自定义操作有问题。有些正在工作,有些没有。我在 VS 2012 中有两个项目 C# CustomAction Project 和 Setup Project。 我的自定义操作如下所示。前两个操作不会导致问题。只有第三个不工作。
[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;
}
我这样定义自定义操作:
<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" />
我的安装顺序如下所示:
<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>
当我评论 <Custom Action="ca_checkProgramsId" After="MsiUnpublishAssemblies">Installed</Custom> 时,一切正常。但是当这部分没有被注释掉时,卸载程序时出现错误There is problem with this Windows Installer package. A DLL required for this install to complete could not be run.。我看不到任何错误。每个名字和身份证都是正确的。我没有使用 PInvoke 或类似的东西。
更新: 自定义操作的目标是检查某些进程是否正在运行并根据它中断卸载过程。设置是每个系统的,我在任何其他自定义操作中的消息框都没有问题。我用另一个自定义动作项目解决了它,该项目本身有问题自定义动作,但除此之外我使用完全相同的方法和设置定义(当然不包括另一个 dll 定义)仍然不知道问题是什么。
【问题讨论】:
-
这将有助于了解您的最终目标是什么。通常不需要自定义操作。
-
我需要检查某些进程是否正在运行,并根据它中断卸载进程。我更新了我的问题。
标签: c# wix custom-action wix3.8