-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
When setting the configuration for a side, if the CurrentMode is Site and the $Config.Value (the site name) does not exist in the target SiteCombo's items, the script attempts to set the Text property of the combobox. Since this combobox has its DropDownStyle set to DropDownList, this will cause an exception. This can happen when copying or swapping between sides that have different lists of IIS sites.
The correct behavior would be to handle this case gracefully, for example by clearing the selection when the site is not found.
if ($state.CurrentMode -eq "Site") {
if ($Config.Value) {
$index = $state.SiteCombo.Items.IndexOf($Config.Value)
if ($index -ge 0) {
$state.SiteCombo.SelectedIndex = $index
}
else {
# Site from source/other side doesn't exist here, so clear selection.
$state.SiteCombo.SelectedIndex = -1
}
}
else {
$state.SiteCombo.SelectedIndex = -1
}
}
Originally posted by @gemini-code-assist[bot] in #1 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels