Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect startup, outdated directory selection window #1734

Open
alexeygritsenko opened this issue Jan 28, 2025 · 3 comments
Open

Incorrect startup, outdated directory selection window #1734

alexeygritsenko opened this issue Jan 28, 2025 · 3 comments

Comments

@alexeygritsenko
Copy link

alexeygritsenko commented Jan 28, 2025

Hi, I decided to try the latest WixSharp. The project was created using the "WixSharp Managed Setup - Custom WPF UI (WIX3)" template (it's the same problems in the WIX4 version).

  1. The build was successful. But when I try to install the program on a computer with an older .Net framework I see the following

Image

instead, a warning should be issued and the dependency should be installed if the user agrees.

  1. When I select a directory for installation, an outdated and inconvenient directory selection window opens

Image

It has not been used for a long time.
Instead, the user should see a full-fledged selection window, with full navigation, example
Image

@oleg-shilo
Copy link
Owner

  1. Some older (but relatively recent) release had this problem with extracting the resource image at runtime. Thus you might be using an older version of WixSharp and your problem may not be related to the .NET version. I have attached the sample project that shows the correct extraction at least on Win10/11. If this project still shows no image you can then provide your custom implementation of the banner image initialization:

    // WPF
    public BitmapImage Banner => session?.GetResourceBitmap("WixSharpUI_Bmp_Dialog")?.ToImageSource() ??
                                 session?.GetResourceBitmap("WixUI_Bmp_Dialog")?.ToImageSource();
    
    // WinForms
    void WelcomeDialog_Load(object sender, EventArgs e)
    {
        image.Image = Runtime.Session.GetResourceBitmap("WixUI_Bmp_Dialog") ??
                      Runtime.Session.GetResourceBitmap("WixSharpUI_Bmp_Dialog");
    
        if (image.Image != null)
            ResetLayout();
    }
  2. "When I select a directory for installation, an outdated and inconvenient directory selection window opens"
    Unfortunately, .NET Framework does not provide any way to access the latest Windows API for folder selection and what you see is the one that is possible with .NET Framework. When you use native MSI stock dialgs, MSI runtime accesses that new API that's why this dialog looks better when using default UI.

    You can still switch to a modern dialog style by yourself by replacing the new FolderBrowserDialog (in the code sample) with an alternative implementation.

    void change_Click(object sender, EventArgs e)
    {
        using (var dialog = new FolderBrowserDialog { SelectedPath = installDir.Text })
        {
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                installDir.Text = dialog.SelectedPath;
            }
        }
    }

    The implementation of the new style Windows API dialog is beyond the scope WixSharp so you will need to do your own research here.
    According to ChatGPT it's not that difficult. I even included the code in the sample. But it throws the COM exception at runtime. So you may want to troubleshoot it a little.

WixSharp Setup2.zip

@alexeygritsenko
Copy link
Author

  1. It's not just the banner. Even the captions don't load. And when you click "Next", it crashes. So it's related to the framework version

Image
2. Ok

@oleg-shilo
Copy link
Owner

So it's related to the framework version

Indeed it may be but the fact that the dialog was created indicates that the CLR is at least partially compatible.
I suggest you debug it and see which method call upsets the dialog initialization. Most likely, there will be some API that is not available in outdated CLR. If you identify the offending API call, you can replace it with an alternative. You do have the source code for all dialogs.

If debugging is a challenge then you can use simple logging with extra exception handling in the dialog initialization. This is what I would do.

You can also play with project.CAConfigFile = "<path to your custom CustomAction.config file>". But the default one seems to do a good job since the target CLR loads the dialogs successfully and only their initialization fails.

And of course, you may consider a precondition for the supported .NET to be present on the target OS. After all NET Framework 4.5. 2, 4.6, and 4.6. 1 retired on April 26, 2022.

oleg-shilo added a commit that referenced this issue Feb 1, 2025
- WIP: Added support for modern style folder selection dialog (triggered by #1734 discussion)
- Added a more convenient option to play dialogs in demo mode during development
oleg-shilo added a commit that referenced this issue Feb 1, 2025
- #1736: Issue with Special Characters in WixSharp Bootstrapper Custom BA after Upgrading from Wix3 to Wix4
- Improved positioning of the background images for WPF UI Dialogs
- WIP: Added support for modern style folder selection dialog (triggered by #1734 discussion)
- Added a more convenient option to play dialogs in demo mode during development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants