Opening WinForms window in Inno Setup not working on older Windows versions











up vote
5
down vote

favorite
1












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.



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.










share|improve this question
























  • 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















up vote
5
down vote

favorite
1












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.



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.










share|improve this question
























  • 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













up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





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.



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.










share|improve this question















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.



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin