简体   繁体   English

无法使用WiX安装程序进行设置

[英]Unable to setup with WiX Installer

I created a Setup with WiX Installer for my C# application. 我使用WiX安装程序为C#应用程序创建了安装程序。

I use a Class CustomAction to install a SQL data base and setting rights to a folder. 我使用CustomAction类安装SQL数据库并设置文件夹的权限。

There is my Class : 有我的课:

public class CustomActions
{
    [CustomAction]
    public static ActionResult AllowAppData(Session session){...}

    [CustomAction]
    public static ActionResult Install_SetupDataBase(Session session){...}
}

And the product.wxs : 和product.wxs:

<Binary Id="CASetup.dll" SourceFile="$(var.SetupCustomAction.TargetDir)$(var.SetupCustomAction.TargetName).CA.dll" />
<CustomAction Id="CustomActionSetupAllow" BinaryKey="CASetup.dll" DllEntry="AllowAppData" Execute="immediate" />
<CustomAction Id="CustomActionSetupBase" BinaryKey="CASetup.dll" DllEntry="Install_SetupDataBase" Execute="immediate" />

<InstallExecuteSequence>
  <Custom Action='CustomActionSetupAllow' After='InstallFinalize' />
  <Custom Action='CustomActionSetupBase' After='InstallFinalize' />
</InstallExecuteSequence>

The build is ok but when the Install perform I have the message : 构建正常,但是当执行安装时,我收到消息:

在此处输入图片说明

I've try with only CustomActionSetupAllow and it's works fine. 我尝试仅使用CustomActionSetupAllow ,而且效果很好。 But with CustomActionSetupBase I got the message. 但是有了CustomActionSetupBase我得到了消息。

How can I know what DLL are missing ? 我怎么知道缺少什么DLL? And where should I add a reference ? 我应该在哪里添加参考?

The error "could not be run" doesn't mean it's missing. 错误“无法运行”并不意味着它已丢失。 It's in the Binary table of the MSI file and will be streamed out onto disk to run. 它位于MSI文件的Binary表中,并将被流式传输到磁盘上以运行。 The error means that it doesn't load and run, or is crashing. 该错误意味着它无法加载和运行,或者正在崩溃。 It's possible that there are missing dependent Dlls. 有可能缺少依赖的Dll。

One potentially serious problem is that you've marked the custom action (CA) to be immediate. 一个潜在的严重问题是您已将自定义操作(CA)标记为立即执行。 That means it runs before anything has been installed, such as perhaps the empty database you might be populating, as well as any dependent Dlls it might need. 这意味着它可以在安装任何东西之前运行,例如您可能正在填充的空数据库,以及它可能需要的任何依赖的Dll。 Apart from that, if you create the SQL DB with an immediate CA and the install subsequently fails so you'll have a DB but no installed product. 除此之外,如果您使用直接CA创建SQL DB,并且安装随后失败,那么您将拥有一个DB但没有安装产品。 It should be a deferred custom action, ideally with a rollback CA to remove the DB so the user can run the install again and you don't populate the same DB again, if that's an issue. 这应该是一个延迟的自定义操作,最好是使用回滚CA来删除该数据库,以便用户可以再次运行安装,而不必再填充同一数据库(如果有问题)。

There are other areas you may want to look at. 您可能还需要查看其他领域。 An immediate CA runs with the installing user's credential and not elevated, so if the code requires elevation it will fail. 即时CA使用安装用户的凭据而不是提升的身份运行,因此,如果代码需要提升,它将失败。 A deferred CA will run elevated with the system account, so access to a SQL DB with the system account might be an issue. 延迟的CA将随系统帐户一起运行,因此使用系统帐户访问SQL DB可能是一个问题。 Code in a CA needs to be very defensive because it's not the same environment as an interactive test. CA中的代码必须具有很高的防御性,因为它与交互式测试的环境不同。 For these reasons it's often better to do this with a startup program that runs in a true interactive environment when the app first runs. 由于这些原因,通常最好使用在应用程序首次运行时在真正的交互式环境中运行的启动程序来执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM