Hi,
I'm having a problem serialising a List of Objects.
Each object is a class, whose attributes are derived from a schema table returned by an SQL query.
The data-type of each object is determined using reflection and at the same time a .dll is built.
The eventual plan is that after the data is retrieved, the newly populated List of Objects is serialised to XML and then de-serialised into a separate application. To gain access to the attributes of the newly created POCO a '.dll' is generated.
The problem arises when attempting to serialise this class:
List<Type> noDuplicates = expectedTypes.Distinct().ToList();
con.Message( "starting serialization" );
XmlSerializer serializer = new XmlSerializer( , noDuplicates.ToArray<Type>());
MemoryStream stream = new MemoryStream();
serializer.Serialize(stream, outputList);
When passing the type into the XmlSerializer I am unsure how to get the type of the reflected POCO that has been created.
Thank you in advance for any feedback or solutions.
Larrythemule
-- Addition --
Hi,
I have tried this since posting last time:
const string TypeName = "myType";
//Code
TypeBuilder tb = mb.DefineType( TypeName, TypeAttributes.Public | TypeAttributes.Serializable );
// Some Code
Type generatedType = tb.CreateType();
ab.Save( aName.Name + ".dll" );
XmlSerializer serializer = new XmlSerializer(generatedType, noDuplicates.ToArray<Type>());
This was an attempt to pass the correct type into the XMLSerialiser. Instead of throwing an exception immediately, there was a pause, suggesting that the document was at least partially serialised. The same exception was thrown however.
Thanks again.