Dictionary types by default cannot be serialized to XML format. The following class can be serialized and is used virtually identically to the standard dictionary class. I can't guarantee this will work for 100% of your applications but it should work for most. Ideally just use a list or something instead. If you're going to use this anyway make sure any classes you used for the dictionary value are serializable and make sure your key is of type string.
This code was generated with the help of Chat GBT.