GetXmlNamespaceMaps type change

The backing property of XmlAttributeProperties.XmlNamespaceMaps has been changed from String to Hashtable.

Version introduced

.NET 9 Preview 3

Previous behavior

Previously, the backing property of XmlNamespaceMaps was String. However, the value returned by dependencyObject.GetValue(XmlNamespaceMapsProperty) is of type Hashtable and the GetXmlNamespaceMaps(DependencyObject) implementation tried to type cast it to String, which resulted in an InvalidCastException.

In addition, the SetXmlNamespaceMaps(DependencyObject, String) method accepted a String argument.

New behavior

Starting in .NET 9, the backing property of XmlNamespaceMaps is Hashtable, and the InvalidCastException is no longer thrown by GetXmlNamespaceMaps(DependencyObject).

In addition, the SetXmlNamespaceMaps(DependencyObject, Hashtable) method now accepts a Hashtable argument.

Change category

This change is a behavioral change and can also affect source compatibility.

Reason for change

This change was made to prevent the InvalidCastException from being thrown.

Pass Hashtable instead of a string to the SetXmlNamespaceMaps API.

Affected APIs