How can I serialize a list of Exception objects (also including derived exceptions, eg. FileNotFoundException) with the DataContractSerializer?
I always get an error about the serializer not knowing the types in the list so i devised a workaround.
It looked something like this:
Dim XmlSerializer As New DataContractSerializer(ExceptionsList.GetType(), ExceptionsList.Select(Function(i) i.GetType))
XmlSerializer.WriteObject(Stream, List)
This works. I just add all the different exception types to the list of known types and it works. But on deserialization I am stuck. The problem is i dont know the types of exceptions stored in the file beforehand.
Any ideas?