Convert.ChangeType does not support Guids

I suppose one can argue that this is not a “bug”, but it sure feels like one to me
-- the following Convert.ChangeType, with a Guid type, throws an exception:

Convert.ChangeType(”12345678-1234-1234-1234-1234567890AB”, typeof(Guid))

Note that this is easy enough to resolve, since you can use new Guid() instead,
but this isn't what you are expecting to do when converting types that are dynamic.

1 Comment

  • There's a nasty one associated with DataTable as well. ADO.NET will let you assign a text string to a GUID column of a DataTable, but then crashes with the casting error when you attempt to save it.

    I reported this under 1.0 and it came back "by design" - you do wonder who designs this stuff sometimes :-)

Comments have been disabled for this content.