Krypton-Suite / Standard-Toolkit

An update to Component factory's krypton toolkit to support .NET Framework 4.6.2 - 4.8.1 to .NET 6 - 8
BSD 3-Clause "New" or "Revised" License
396 stars 60 forks source link

[Bug]: KryptonButton crashes program on invalid type cast. #1708

Closed giduac closed 1 month ago

giduac commented 1 month ago

Describe the bug This part of the button's code needs altering because the owner typecast check is incomplete an leaves out the other 3 types of KMB v ariants

                    // Is it https://github.com/Krypton-Suite/Standard-Toolkit/issues/728
                    if (owner is VisualMessageBoxForm)
                    {
                        // need to gain access to `dialogResult` and set it forcefully
                        FieldInfo? fi = typeof(Form).GetField("dialogResult", BindingFlags.NonPublic | BindingFlags.Instance);
                        if (fi != null)
                        {
                            fi.SetValue(owner, DialogResult);
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }

PR underway