K
Keith Patrick
Does anyone know of a way (without looking through decompiled ASP.Net code)
to convert a String to a Type using the generic TypeConverter stuff? I am
writing a deserializer, but I would prefer not to have a custom codepath
just for String->Type, but the following code throws a
NotSupportedException:
TypeDescriptor.GetConverter(typeof(Type)).ConvertFrom("System.String")
The problem with the above code is that GetConverter returns the base
TypeDescriptor, which always throws an exception on ConvertFrom, but I'm not
aware of any gneeric codepaths to do this that don't involve typedescriptors
to convert a String to a Type using the generic TypeConverter stuff? I am
writing a deserializer, but I would prefer not to have a custom codepath
just for String->Type, but the following code throws a
NotSupportedException:
TypeDescriptor.GetConverter(typeof(Type)).ConvertFrom("System.String")
The problem with the above code is that GetConverter returns the base
TypeDescriptor, which always throws an exception on ConvertFrom, but I'm not
aware of any gneeric codepaths to do this that don't involve typedescriptors