如何从我的应用程序安装目录中获取MSI(使用InstallShield)加载Microsoft.Deployment.WindowsInstaller dll?

时间:2013-10-26 20:20:39

标签: wix installshield custom-action

我有一个非常简单的托管CA,它使用Microsoft.Deployment.WindowsInstaller:

[CustomAction]
public static ActionResult TestDtf(Session session)
{
    MessageBox.Show("Test");
    ActionResult result = ActionResult.Success;
    return result;

}

我用net4编译它。我在InstallShield2012中有一个托管CA'存储在二进制表'中,方法签名方法= TestDtf,arguments = value:MsiHandle,参数:Microsoft.Deployment.WindowsInstaller

我不确定我是否说得对,但即使这不是我的直接问题。问题似乎是msiexec只在系统文件夹中查找Microsoft.Deployment.WindowsInstaller.dll,而不是像我刚安装此程序集的文件夹那样,并确认它在CopyFiles之后就存在。

这是部分日志:

InstallShield: Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad'
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
   at System.Reflection.RuntimeMethodInfo.GetParameters()
   at InstallShield.ClrHelper.CustomActionHelper.PrepareParameters(EntryPointInfo info, Boolean& anyHidden)

如果我手动将Microsoft.Deployment.WindowsInstaller.dll删除到syswow64中,它会正常加载。我不确定是否要将其安装到我们的客户系统文件夹中,但是......

如何设置我的安装程序以便它可以找到Microsoft.Deployment.WindowsInstaller.dll?

2 个答案:

答案 0 :(得分:2)

你说这一切都错了。当您构建DTF项目FOO时,您将获得FOO.DLL和FOO.CA.DLL。这是您作为Windows Installer DLL自定义操作添加到InstallShield的FOO.CA.DLL。 DTF将FOO.DLL包装在FOO.CA.DLL中,并为您打包包括Microsoft.Deployment.WindowsInstaller.dll互操作在内的任何其他文件。

看看:

http://blog.iswix.com/2008/05/deployment-tools-foundation-dtf-managed.html

将FOO.CA.DLL重命名为FOO.CA.ZIP并在7Zip或WinZip中打开它。你会在那里看到其他文件。

答案 1 :(得分:0)

看起来解决这个问题的方法是在ISClrWrap表中创建一个条目:

Action: {nameOfCustomAction}
Name: Dependency0
Value: Path to the dependency in this case Microsoft.Deployment.WindowsInstaller.dll (you can use a path variable with this)