JCDenton Posted November 17, 2008 Posted November 17, 2008 Attempting to serialize all the type information contained in an assembly. To test my code I'm using a SharpDevelop assembly. However, when running: StringWriter sw = new StringWriter(); XmlSerializer XmlSer = new XmlSerializer(typeof (Type[])); XmlSer.Serialize(sw, TargetAss.GetTypes()); The code breaks with error {"There was an error generating the XML document."} {"Cannot serialize interface ICSharpCode.SharpDevelop.Gui.ICanBeDirty."} Why would it try to serialize interface ICanBeDirty ? All I need of the Type is MethodInfo, properties, etc. Thanks all Quote
MrPaul Posted November 27, 2008 Posted November 27, 2008 Cannot serialize types in XML This is a quirk of XML serialization - it cannot serialize types. Just try and serialize any type using the XmlSerializer and you will get an exception of some sort. The only solution is to represent each type in some other form (e.g. string), or use a different serialization formatter. Good luck :cool: Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.