bkwdesign
bkwdesign

Reputation: 2117

Windows Forms 4.8 dialog modal works in Visual Studio 2022 IDE but not after being installed via MSI

TL;DR bindingSource.CurrentChanged event seems to fire OK during IDE debugging, but, not in the final installed, 'Release'-compiled application - other event handlers seem to behave as desired.

Goal: A custom windows dialog can be launched from a custom UserControl. The dialog features a DataGridView that will cause various sibling TextBox controls to update when the current row is changed. If the user wants, they can modify text in the text controls and use a button to dismiss the dialog, however, if no textual customization is required, they can also simply double-click a desired row in the DataGridView and dismiss the dialog. Regardless of how the dialog is dismissed, a couple of static properties are set on the dialog class, and these are used by the hosting user control if the DialogResult.OK was returned from calling the .ShowDialog method

Buggy Behavior1: The dialog can be launched and dismissed successfully in the IDE (both in debug and release modes) but if I install the application using my preferred MSI packaging technique, the same dialog will launch and dismiss but the host user control is not updated with anything. It is as if the static properties on the dialog class I spoke of earlier are not being set.

Buggy Behavior2: The mis-behaving dialog (again, the installed version of the application) shows the DataGridView (so it binds data successfully) but the interaction of current row, when it changes, does not affect the TextBox controls that allow for user customization. It's as if there's no event bubbling/registration going on.

Solution Structure: My windows application is divided into two parts, a primary executable with a Start form (as you would expect) with many controls and dialogs in a dependent library. Because I experimented with event log registration, the dependent controls library is also an .exe even though for the most part it merely functions like a *.dll for all intents and purposes.

Bewildering factors: Not much history in this single-owner git repo. I last made major changes to the project about a year ago when I took it from a traditional *.csproj structure to an SDK style *.csproj. This was supposed to be routine feature add. I even have some tests in my Azure DevOps pipeline that guarantee the stability of many of the usercontrol's behavior (of course, not this specific dialog, however). Hard to see a smoking gun in the codebase at this point

UserControl click handler to launch UnnaDotHelperDialog

private void btnUnnaLookup_Click(object sender, EventArgs e)
{
    this.TextEntryInProgress = false;
    if (UnnaDotHelperDialog.ShowDialog(this.txtUnna.Text) == DialogResult.OK)
    {
        this.txtDescription.Text = UnnaDotHelperDialog.FormulatedDotShippingName;
        this.txtUnna.Text = UnnaDotHelperDialog.SelectedUnnaNumber;
        WasteFlattened wasteFlattened = (WasteFlattened)this.wasteFlattenedBindingSource.Current;
        wasteFlattened.Description = UnnaDotHelperDialog.FormulatedDotShippingName;
        wasteFlattened.UnnaNumber = UnnaDotHelperDialog.SelectedUnnaNumber;
        if (UnnaDotHelperDialog.SelectedErgNumber != null)
        {
            this.OnResourceGuideNumberSuggested(UnnaDotHelperDialog.SelectedErgNumber.Value);
        }
    }
}

My Custom UnnaDotHelperDialog.ShowDialog Factory method

    ///
    /// pass in search term from host user-control
    ///
    public static DialogResult ShowDialog(string unnaSearchText)
    {
        UnnaDotHelperDialog dlg = new UnnaDotHelperDialog();
        dlg.txtSearchUnna.Text = unnaSearchText;//echo search term in top of dialog
        dlg.txtSearch_KeyDown(dlg.txtSearchUnna, new KeyEventArgs(Keys.Return));//execute search, pop DataGridView
        return dlg.ShowDialog();
    }

Upvotes: -2

Views: 73

Answers (1)

bkwdesign
bkwdesign

Reputation: 2117

Thanks to everyone who bothered reading my dreadful tale.

After additional interaction with other parts of the dialog, I'm saw that some other DLL references aren't loading. Got the old FileNotFoundException

System.IO.FileNotFoundException: Could not load file or assembly 'MyCorp_Interfaces, Version=2.0.1.0,...

At first I thought I needed to play with Binding References and adding junk to my app.config... but then it dawned on me to actually look at the installed application folder. The DLLs were actually not there.

Once I copied the missing dll's into the installed location, my app began working. These "loose" dlls are static files in my solution referenced the old fashioned way (not via NuGet) and something has happened in my installer project causing it to not bundle them as part of the project output. I'm sure once I fix that, I'll be all set.

Upvotes: -1

Related Questions