The exception is thrown when the color for the borders has been previously set using the colors from the predefined palette. The next attempt to set a border color using the ShowMoreColorsDialog leads to error. A message appears to the user saying "Specified cast is not valid".