gpt4 book ai didi

.net - 一个 Windows 安装程序中的 32 位和 64 位程序集

转载 作者:行者123 更新时间:2023-12-04 14:20:13 25 4
gpt4 key购买 nike

我有一个用 C# 编写的应用程序,它依赖于 sqlite 托管提供程序。 sqlite 提供程序依赖于平台(对于 32 位和 64 位应用程序有两个同名的 dll)。应用程序在运行时根据操作系统加载所需的应用程序。

问题是,在创建安装程序时,我无法将 64 位模式的 dll 添加到安装项目中,因为我收到以下错误:File '' targeting '' is not compatible with the project's target platform ''.

我会使用其他安装程序,但我有一个必须在安装过程中调用的自定义操作。

所以我想知道是否有安装程序可以让我向其中添加 32 位和 64 位 dll 并执行用 C# 编写的自定义操作。

一种可能的解决方案是有两个安装程序,但如果可能的话,我想避免它。

有什么建议?

最佳答案

Inno Setup安装程序支持您请求的功能,此安装程序非常灵活可靠,网络中存在许多脚本示例,可根据最终客户端的架构进行有条件的安装。

检查位于 C:\Program Files\Inno Setup 5\Examples\64BitThreeArch.iss 中的此脚本

 -- 64BitThreeArch.iss --
; Demonstrates how to install a program built for three different
; architectures (x86, x64, Itanium) using a single installer.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
; "ArchitecturesInstallIn64BitMode=x64 ia64" requests that the install
; be done in "64-bit mode" on x64 & Itanium, meaning it should use the
; native 64-bit Program Files directory and the 64-bit view of the
; registry. On all other architectures it will install in "32-bit mode".
ArchitecturesInstallIn64BitMode=x64 ia64

[Files]
; Install MyProg-x64.exe if running on x64, MyProg-IA64.exe if
; running on Itanium, MyProg.exe otherwise.
Source: "MyProg-x64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: IsX64
Source: "MyProg-IA64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: IsIA64
Source: "MyProg.exe"; DestDir: "{app}"; Check: IsOtherArch
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Code]
function IsX64: Boolean;
begin
Result := Is64BitInstallMode and (ProcessorArchitecture = paX64);
end;

function IsIA64: Boolean;
begin
Result := Is64BitInstallMode and (ProcessorArchitecture = paIA64);
end;

function IsOtherArch: Boolean;
begin
Result := not IsX64 and not IsIA64;
end;

关于.net - 一个 Windows 安装程序中的 32 位和 64 位程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2732930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com