bre*_*eez 5 c# inno-setup dllexport pascalscript winforms
我有一个Inno安装脚本,其中所需的表单太复杂,无法完全在Inno Setup本身构建,所以我在.NET中创建了一个帮助器类库,其中包含一个WinForms窗口,其中包含我需要的东西.
我通过使用Robert Giesecke 的Unmanaged Exports NuGet公开方法在Inno Setup中打开这个WinForms窗口.
这在我运行Windows 10的开发计算机上运行良好.它也可以在运行Windows Server 2012和2016的测试服务器上运行.但是,当我尝试在Windows Server 2008R2计算机上运行安装程序时,出现以下错误:
Sytem.ArgumentException:Font'?' 无法找到.
这是我的Inno安装脚本:
#define MyAppName "InnoTest"
#define MyAppVersion "1.0"
#define MyAppPublisher "Test"
#define MyAppURL "http://inno.test"
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=C:\Users\Admin\Desktop\test_inno
OutputBaseFilename=test_inno_setup_x64
Compression=lzma/Max
SolidCompression=true
[Files]
Source: "C:\Users\Admin\Documents\Visual Studio 2017\Projects\InnoTestNet\InnoTestNet\bin\Release\InnoTestNet.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
procedure ShowTestForm(); external 'ShowTestForm@files:InnoTestNet.dll stdcall';
procedure InitializeWizard();
begin
ShowTestForm();
end;
Run Code Online (Sandbox Code Playgroud)
和我的C#代码:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using RGiesecke.DllExport;
namespace InnoTestNet
{
public class InnoTestNet
{
[DllExport("ShowTestForm", CallingConvention = CallingConvention.StdCall)]
public static void ShowTestForm()
{
try
{
var testForm = new TestForm();
testForm.ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经将WinForms窗口缩小到最低限度(只有一个标签).
我尝试过的事情:
Windows Server 2008R2环境是一个完全更新的干净安装,安装了.NET Framework 4.7.2.
类库是.NET Framework 4.5.2的目标.
我使用的是InnoSetup 5.6.1的Unicode版本.
编辑
我发现这个有趣的问题: 使用SetDefaultDllDirectories打破字体处理
看来,当从Windows API调用"SetDefaultDllDirectories"函数时,字体解析可能会被破坏.当进一步追踪Inno Setup 5.5.9的发行说明时,似乎Inno Setup确实称这个有问题的功能.