Opening WinForms window in Inno Setup not working on older Windows versions
up vote
5
down vote
favorite
I have an Inno Setup script where the desired form was too complicated to build entirely in Inno Setup itself, so I created a helper class library in .NET which contains a WinForms window with the things I need.
I open this WinForms window in Inno Setup by exposing the method with the Unmanaged Exports NuGet from Robert Giesecke.
This works perfectly on my development machine running Windows 10. It also works on a test server running Windows Server 2012 and 2016. When I try to run the setup on a Windows Server 2008R2 machine however, I am presented with the following error:
Sytem.ArgumentException: Font '?' cannot be found.
This is my Inno Setup script:
#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:UsersAdminDesktoptest_inno
OutputBaseFilename=test_inno_setup_x64
Compression=lzma/Max
SolidCompression=true
[Files]
Source: "C:UsersAdminDocumentsVisual Studio 2017ProjectsInnoTestNetInnoTestNetbinReleaseInnoTestNet.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
procedure ShowTestForm(); external 'ShowTestForm@files:InnoTestNet.dll stdcall';
procedure InitializeWizard();
begin
ShowTestForm();
end;
and my C# code:
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());
}
}
}
}
I have reduced the WinForms window down to the bare minimum (just one label).
Things I have tried:
- Embedding "Arial.otf" in the class library, loading the font at
runtime with PrivateFontCollection and setting the font on the
WinForm. - Using another font like Calibri or Tahoma
- Changing the font of the InnoSetup installer itself (DefaultDialogFontName)
- Executing "Application.EnableVisualStyles()"
The Windows Server 2008R2 environment is a fully updated clean install with .NET Framework 4.7.2 intalled.
The class library is targeted for .NET Framework 4.5.2.
I am using the Unicode version of InnoSetup 5.6.1.
edit
I found this interesting SO question:
Using SetDefaultDllDirectories breaks Font handling
It appears, when calling the "SetDefaultDllDirectories" function from the Windows API, font resolving might get broken.
When further tracking down the release notes of Inno Setup 5.5.9 it appears Inno Setup is indeed calling this problematic function.
c# winforms inno-setup dllexport pascalscript
|
show 3 more comments
up vote
5
down vote
favorite
I have an Inno Setup script where the desired form was too complicated to build entirely in Inno Setup itself, so I created a helper class library in .NET which contains a WinForms window with the things I need.
I open this WinForms window in Inno Setup by exposing the method with the Unmanaged Exports NuGet from Robert Giesecke.
This works perfectly on my development machine running Windows 10. It also works on a test server running Windows Server 2012 and 2016. When I try to run the setup on a Windows Server 2008R2 machine however, I am presented with the following error:
Sytem.ArgumentException: Font '?' cannot be found.
This is my Inno Setup script:
#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:UsersAdminDesktoptest_inno
OutputBaseFilename=test_inno_setup_x64
Compression=lzma/Max
SolidCompression=true
[Files]
Source: "C:UsersAdminDocumentsVisual Studio 2017ProjectsInnoTestNetInnoTestNetbinReleaseInnoTestNet.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
procedure ShowTestForm(); external 'ShowTestForm@files:InnoTestNet.dll stdcall';
procedure InitializeWizard();
begin
ShowTestForm();
end;
and my C# code:
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());
}
}
}
}
I have reduced the WinForms window down to the bare minimum (just one label).
Things I have tried:
- Embedding "Arial.otf" in the class library, loading the font at
runtime with PrivateFontCollection and setting the font on the
WinForm. - Using another font like Calibri or Tahoma
- Changing the font of the InnoSetup installer itself (DefaultDialogFontName)
- Executing "Application.EnableVisualStyles()"
The Windows Server 2008R2 environment is a fully updated clean install with .NET Framework 4.7.2 intalled.
The class library is targeted for .NET Framework 4.5.2.
I am using the Unicode version of InnoSetup 5.6.1.
edit
I found this interesting SO question:
Using SetDefaultDllDirectories breaks Font handling
It appears, when calling the "SetDefaultDllDirectories" function from the Windows API, font resolving might get broken.
When further tracking down the release notes of Inno Setup 5.5.9 it appears Inno Setup is indeed calling this problematic function.
c# winforms inno-setup dllexport pascalscript
Can you run your form directly without Inno (in test application)?
– Miamy
Nov 18 at 19:43
Yes. I made a console application and referenced the class library from there. Ran without any problem on all systems.
– breez
Nov 18 at 19:44
My guess is Inno Setup is calling a windows API function which breaks the font resolving. But don't know where to look. I also came across this interesting SO question: stackoverflow.com/questions/25818073/…
– breez
Nov 18 at 19:47
What if you run that console application from Inno Setup?
– Martin Prikryl
Nov 18 at 20:00
Also this post suggests the error can be caused by Antivirus: social.msdn.microsoft.com/Forums/en-US/… - Can you try disabling it?
– Martin Prikryl
Nov 18 at 20:01
|
show 3 more comments
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I have an Inno Setup script where the desired form was too complicated to build entirely in Inno Setup itself, so I created a helper class library in .NET which contains a WinForms window with the things I need.
I open this WinForms window in Inno Setup by exposing the method with the Unmanaged Exports NuGet from Robert Giesecke.
This works perfectly on my development machine running Windows 10. It also works on a test server running Windows Server 2012 and 2016. When I try to run the setup on a Windows Server 2008R2 machine however, I am presented with the following error:
Sytem.ArgumentException: Font '?' cannot be found.
This is my Inno Setup script:
#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:UsersAdminDesktoptest_inno
OutputBaseFilename=test_inno_setup_x64
Compression=lzma/Max
SolidCompression=true
[Files]
Source: "C:UsersAdminDocumentsVisual Studio 2017ProjectsInnoTestNetInnoTestNetbinReleaseInnoTestNet.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
procedure ShowTestForm(); external 'ShowTestForm@files:InnoTestNet.dll stdcall';
procedure InitializeWizard();
begin
ShowTestForm();
end;
and my C# code:
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());
}
}
}
}
I have reduced the WinForms window down to the bare minimum (just one label).
Things I have tried:
- Embedding "Arial.otf" in the class library, loading the font at
runtime with PrivateFontCollection and setting the font on the
WinForm. - Using another font like Calibri or Tahoma
- Changing the font of the InnoSetup installer itself (DefaultDialogFontName)
- Executing "Application.EnableVisualStyles()"
The Windows Server 2008R2 environment is a fully updated clean install with .NET Framework 4.7.2 intalled.
The class library is targeted for .NET Framework 4.5.2.
I am using the Unicode version of InnoSetup 5.6.1.
edit
I found this interesting SO question:
Using SetDefaultDllDirectories breaks Font handling
It appears, when calling the "SetDefaultDllDirectories" function from the Windows API, font resolving might get broken.
When further tracking down the release notes of Inno Setup 5.5.9 it appears Inno Setup is indeed calling this problematic function.
c# winforms inno-setup dllexport pascalscript
I have an Inno Setup script where the desired form was too complicated to build entirely in Inno Setup itself, so I created a helper class library in .NET which contains a WinForms window with the things I need.
I open this WinForms window in Inno Setup by exposing the method with the Unmanaged Exports NuGet from Robert Giesecke.
This works perfectly on my development machine running Windows 10. It also works on a test server running Windows Server 2012 and 2016. When I try to run the setup on a Windows Server 2008R2 machine however, I am presented with the following error:
Sytem.ArgumentException: Font '?' cannot be found.
This is my Inno Setup script:
#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:UsersAdminDesktoptest_inno
OutputBaseFilename=test_inno_setup_x64
Compression=lzma/Max
SolidCompression=true
[Files]
Source: "C:UsersAdminDocumentsVisual Studio 2017ProjectsInnoTestNetInnoTestNetbinReleaseInnoTestNet.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
procedure ShowTestForm(); external 'ShowTestForm@files:InnoTestNet.dll stdcall';
procedure InitializeWizard();
begin
ShowTestForm();
end;
and my C# code:
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());
}
}
}
}
I have reduced the WinForms window down to the bare minimum (just one label).
Things I have tried:
- Embedding "Arial.otf" in the class library, loading the font at
runtime with PrivateFontCollection and setting the font on the
WinForm. - Using another font like Calibri or Tahoma
- Changing the font of the InnoSetup installer itself (DefaultDialogFontName)
- Executing "Application.EnableVisualStyles()"
The Windows Server 2008R2 environment is a fully updated clean install with .NET Framework 4.7.2 intalled.
The class library is targeted for .NET Framework 4.5.2.
I am using the Unicode version of InnoSetup 5.6.1.
edit
I found this interesting SO question:
Using SetDefaultDllDirectories breaks Font handling
It appears, when calling the "SetDefaultDllDirectories" function from the Windows API, font resolving might get broken.
When further tracking down the release notes of Inno Setup 5.5.9 it appears Inno Setup is indeed calling this problematic function.
c# winforms inno-setup dllexport pascalscript
c# winforms inno-setup dllexport pascalscript
edited Nov 18 at 19:59
asked Nov 18 at 18:38
breez
1,0891417
1,0891417
Can you run your form directly without Inno (in test application)?
– Miamy
Nov 18 at 19:43
Yes. I made a console application and referenced the class library from there. Ran without any problem on all systems.
– breez
Nov 18 at 19:44
My guess is Inno Setup is calling a windows API function which breaks the font resolving. But don't know where to look. I also came across this interesting SO question: stackoverflow.com/questions/25818073/…
– breez
Nov 18 at 19:47
What if you run that console application from Inno Setup?
– Martin Prikryl
Nov 18 at 20:00
Also this post suggests the error can be caused by Antivirus: social.msdn.microsoft.com/Forums/en-US/… - Can you try disabling it?
– Martin Prikryl
Nov 18 at 20:01
|
show 3 more comments
Can you run your form directly without Inno (in test application)?
– Miamy
Nov 18 at 19:43
Yes. I made a console application and referenced the class library from there. Ran without any problem on all systems.
– breez
Nov 18 at 19:44
My guess is Inno Setup is calling a windows API function which breaks the font resolving. But don't know where to look. I also came across this interesting SO question: stackoverflow.com/questions/25818073/…
– breez
Nov 18 at 19:47
What if you run that console application from Inno Setup?
– Martin Prikryl
Nov 18 at 20:00
Also this post suggests the error can be caused by Antivirus: social.msdn.microsoft.com/Forums/en-US/… - Can you try disabling it?
– Martin Prikryl
Nov 18 at 20:01
Can you run your form directly without Inno (in test application)?
– Miamy
Nov 18 at 19:43
Can you run your form directly without Inno (in test application)?
– Miamy
Nov 18 at 19:43
Yes. I made a console application and referenced the class library from there. Ran without any problem on all systems.
– breez
Nov 18 at 19:44
Yes. I made a console application and referenced the class library from there. Ran without any problem on all systems.
– breez
Nov 18 at 19:44
My guess is Inno Setup is calling a windows API function which breaks the font resolving. But don't know where to look. I also came across this interesting SO question: stackoverflow.com/questions/25818073/…
– breez
Nov 18 at 19:47
My guess is Inno Setup is calling a windows API function which breaks the font resolving. But don't know where to look. I also came across this interesting SO question: stackoverflow.com/questions/25818073/…
– breez
Nov 18 at 19:47
What if you run that console application from Inno Setup?
– Martin Prikryl
Nov 18 at 20:00
What if you run that console application from Inno Setup?
– Martin Prikryl
Nov 18 at 20:00
Also this post suggests the error can be caused by Antivirus: social.msdn.microsoft.com/Forums/en-US/… - Can you try disabling it?
– Martin Prikryl
Nov 18 at 20:01
Also this post suggests the error can be caused by Antivirus: social.msdn.microsoft.com/Forums/en-US/… - Can you try disabling it?
– Martin Prikryl
Nov 18 at 20:01
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364250%2fopening-winforms-window-in-inno-setup-not-working-on-older-windows-versions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you run your form directly without Inno (in test application)?
– Miamy
Nov 18 at 19:43
Yes. I made a console application and referenced the class library from there. Ran without any problem on all systems.
– breez
Nov 18 at 19:44
My guess is Inno Setup is calling a windows API function which breaks the font resolving. But don't know where to look. I also came across this interesting SO question: stackoverflow.com/questions/25818073/…
– breez
Nov 18 at 19:47
What if you run that console application from Inno Setup?
– Martin Prikryl
Nov 18 at 20:00
Also this post suggests the error can be caused by Antivirus: social.msdn.microsoft.com/Forums/en-US/… - Can you try disabling it?
– Martin Prikryl
Nov 18 at 20:01