3

I am trying to serialize a large object, this has worked for months if not years now and a recent revision has caused this bug to occur in older files.

When re-serializing them I receive a message saying that TypeLoadExceptionHolder is not marked as 'Serializable'. I have set a breakpoint immediately before the serialization call and cannot seem to find any reference that is of that type. Is there anyway to 'scan' the object I am trying to serialize and see where the reference to the TypeLoadExceptionHolder is?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
jimmyjambles
  • 1,631
  • 2
  • 20
  • 34
  • What was revised? Was the object itself changed? If so, how was the object changed? – jeuton Feb 12 '13 at 18:31
  • No changes to the object, my initial reaction was along the lines of what you've asked. I have tracked down that TypeLoadExceptionHolder to a part of the structure with hundreds of list items, not sure how to find which one has the extraneous object though. – jimmyjambles Feb 12 '13 at 18:41

1 Answers1

3

There are a number of scenarios that can trigger this type of exception. A few more common are here and here.

(Summarizing from the above links) In a nutshell binary serialization doesn't throw exceptions when a type cannot be serialized. Instead, it replaces the unserializable type with TypeLoadExceptionHolder type. On top of not being not very well documented, it's reason for being used is even less so.

You may be stuck with manually figuring out what has changed in the object that you are trying to serialize. Specifically, look for:

  • Namespace changes.
  • Member name changes.
  • Member data type changes.
jeuton
  • 543
  • 3
  • 7
  • Thanks for your help, I knew which object had been modified, was just having trouble locating the reference to it, ended up looping a try block to find the anomaly – jimmyjambles Feb 13 '13 at 15:10
  • Another good way to figure out which type is failing for serialization / deserialization is in [this answer](https://stackoverflow.com/a/7493675/7120031). It helped me figure out a deserialization error in a nested type. – Burhan Dec 06 '21 at 19:17