2009-10-27 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 27 Oct 2009 09:55:47 +0000 (09:55 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 27 Oct 2009 09:55:47 +0000 (09:55 -0000)
* ObjectStateFormatter.cs: do not use a type converter to
serialize an object if the converter is an instance of
TypeConverter itself - its reported capability of converting to
string is not useful here.

svn path=/trunk/mcs/; revision=144894

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs

index ef8b784e39e401bc314e3fe6c1cd362b71decc54..3ce50106f8ea7c001f6c616f5168e1930c5406ab 100644 (file)
@@ -1,3 +1,10 @@
+2009-10-27  Marek Habersack  <mhabersack@novell.com>
+
+       * ObjectStateFormatter.cs: do not use a type converter to
+       serialize an object if the converter is an instance of
+       TypeConverter itself - its reported capability of converting to
+       string is not useful here.
+
 2009-10-12  Marek Habersack  <mhabersack@novell.com>
 
        * ObjectStateFormatter.cs: if a type is associated with a type
index 86dbd54fef6c8b17c3593d4d578e438c222e1024..f8f7ce656e92acc6d5ed1352d6b37e09b0606c0e 100644 (file)
@@ -433,7 +433,13 @@ namespace System.Web.UI {
                                                                                t,
                                                                                converter != null ? converter.CanConvertFrom (t) : false));
 #endif
-                                               if (converter == null || !converter.CanConvertTo (typeof (string)))
+                                               // Do not use the converter if it's an instance of
+                                               // TypeConverter itself - it reports it is able to
+                                               // convert to string, but it's only a conversion
+                                               // consisting of a call to ToString() with no
+                                               // reverse conversion supported. This leads to
+                                               // problems when deserializing the object.
+                                               if (converter == null || converter.GetType () == typeof (TypeConverter) || !converter.CanConvertTo (typeof (string)))
                                                        fmt = binaryObjectFormatter;
                                                else {
                                                        typeConverterFormatter.Converter = converter;