0
我的问题是明确的窗口具有访问DLL InstallTools.dll
因为我打电话里面OpenExeUrl
如何使DLL内的Wix调用函数没有错误?
这里的功能是我的DLL内容问题
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.Configuration;
using System.Diagnostics;
namespace InstallTools
{
public class InstallHelper
{
[CustomAction]
public static ActionResult OpenExeUrl(Session session)
{
try
{
var exeUrl = InstallTools.Properties.Settings.Default.EXEURL;
// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
int exitCode = 0;
// Enter in the command line arguments, everything you would enter after the executable name itself
//start.Arguments = arguments;
// Enter the executable to run, including the complete path
start.FileName = exeUrl;
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Maximized;
start.CreateNoWindow = true;
// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
proc.WaitForExit();
// Retrieve the app's exit code
exitCode = proc.ExitCode;
}
}
catch (Exception e)
{
var errorMessage = "Cannot open exe file ! Error message: " + e.Message;
session.Log(errorMessage);
}
return ActionResult.Success;
}
}
}
的维克斯文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MySetup" Language="1033" Version="1.0.0.0" Manufacturer="Sofar" UpgradeCode="c151e7ab-b83a-445f-93b2-2ab7122ea34b">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="MySetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Binary Id="InstallTools" SourceFile="$(var.SolutionDir)InstallTools\bin\$(var.Configuration)\InstallTools.dll"/>
<Binary Id="NotepadPlus" SourceFile="C:\Program Files (x86)\Notepad++\notepad++.exe"/>
<CustomAction Id="OpenExe" BinaryKey="InstallTools" DllEntry="OpenExeUrl" Execute="deferred" Impersonate="yes" />
<!--<CustomAction Id="OpenExe" Return="ignore" Directory="ProgramFilesFolder" ExeCommand="C:\Program Files (x86)\Notepad++\notepad++.exe" Impersonate="yes" Execute="deferred"/>-->
<InstallExecuteSequence>
<Custom Action="OpenExe" Before='InstallFinalize'/>
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MySetup" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="myAppFile">
<File Source="$(var.MyApplication.TargetPath)" />
</Component>
</DirectoryRef>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<ComponentRef Id="myAppFile" />
<!-- </Component> -->
</ComponentGroup>
</Fragment>
</Wix>
您可以注意到我通过构建自定义操作并将其添加到执行顺序来调用dll。
<CustomAction Id="OpenExe" BinaryKey="InstallTools" DllEntry="OpenExeUrl" Execute="deferred" Impersonate="yes" />
<!--<CustomAction Id="OpenExe" Return="ignore" Directory="ProgramFilesFolder" ExeCommand="C:\Program Files (x86)\Notepad++\notepad++.exe" Impersonate="yes" Execute="deferred"/>-->
<InstallExecuteSequence>
<Custom Action="OpenExe" Before='InstallFinalize'/>
</InstallExecuteSequence>
我的问题是,当我启动安装程序时,出现以下屏幕截图所示的此错误。
您能否请指教?
对不起@Chris Eelmaa但您的修复程序无法解决问题。 – Sofiane 2014-10-09 20:27:37
更新了,现在呢?您应该阅读以下内容:http://blogs.msdn.com/b/jschaffe/archive/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters.aspx并执行msiexec/l * out.log查看完整日志。问题也可能是平台不匹配。问题自定义操作根本没有得到执行,或者自定义操作是否在实现中失败?使用session.Log()来查明。 – 2014-10-09 20:32:16
我很抱歉,但仍然没有。 – Sofiane 2014-10-09 21:09:01